|
@ -1,7 +1,7 @@ |
|
|
#include "depositMoney.h" |
|
|
#include "depositMoney.h" |
|
|
#include "updateCustomerAccountBalance.c" |
|
|
#include "updateCustomerAccountBalance.c" |
|
|
|
|
|
|
|
|
void AskToTryAgain(bool afterError){ |
|
|
|
|
|
|
|
|
void askToTryAgain(bool afterError){ |
|
|
char choice; |
|
|
char choice; |
|
|
printf("\n"); |
|
|
printf("\n"); |
|
|
if(afterError){ |
|
|
if(afterError){ |
|
@ -12,7 +12,7 @@ void AskToTryAgain(bool afterError){ |
|
|
scanf(" %c", &choice); |
|
|
scanf(" %c", &choice); |
|
|
switch(choice){ |
|
|
switch(choice){ |
|
|
case 'y': |
|
|
case 'y': |
|
|
DepositMoney(1234,500); |
|
|
|
|
|
|
|
|
depositMoney(1234,500); |
|
|
break; |
|
|
break; |
|
|
case 'n': |
|
|
case 'n': |
|
|
break; |
|
|
break; |
|
@ -20,31 +20,31 @@ void AskToTryAgain(bool afterError){ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int DepositMoney(int customerID, float amountToDeposit){ |
|
|
|
|
|
|
|
|
bool depositMoney(int customerID){ |
|
|
|
|
|
|
|
|
float availableAccountBalance=getAvailableAccountBalance(customerID); |
|
|
float availableAccountBalance=getAvailableAccountBalance(customerID); |
|
|
|
|
|
|
|
|
|
|
|
float amountToDeposit = 0; |
|
|
|
|
|
|
|
|
|
|
|
scanf("%f", &amountToDeposit); |
|
|
|
|
|
|
|
|
if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ |
|
|
if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ |
|
|
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); |
|
|
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); |
|
|
if(updateAvailableAccountBalance(customerID, amountToDeposit, true)==0){ |
|
|
if(updateAvailableAccountBalance(customerID, amountToDeposit, true)==0){ |
|
|
printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); |
|
|
printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); |
|
|
AskToTryAgain(false); |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
askToTryAgain(false); |
|
|
|
|
|
return true; |
|
|
}else{ |
|
|
}else{ |
|
|
printf("Something went wrong. Please contact staff."); |
|
|
printf("Something went wrong. Please contact staff."); |
|
|
return 3; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
}else if(amountToDeposit>0){ |
|
|
}else if(amountToDeposit>0){ |
|
|
printf("The amount you entered is lower than the minimum amount."); |
|
|
printf("The amount you entered is lower than the minimum amount."); |
|
|
AskToTryAgain(true); |
|
|
|
|
|
return 1; //amount lower than minimum deposit amount |
|
|
|
|
|
|
|
|
askToTryAgain(true); |
|
|
|
|
|
return false; //amount lower than minimum deposit amount |
|
|
}else{ |
|
|
}else{ |
|
|
printf("Invalid input."); |
|
|
printf("Invalid input."); |
|
|
AskToTryAgain(true); |
|
|
|
|
|
return 2; //invalid input |
|
|
|
|
|
|
|
|
askToTryAgain(true); |
|
|
|
|
|
return false; //invalid input |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int main() |
|
|
|
|
|
{ |
|
|
|
|
|
DepositMoney(1234,500); |
|
|
|
|
|
} |
|
|
|