Browse Source

Fix an error of deposit function

remotes/origin/feature/transfer-money
fdlt3817 2 years ago
parent
commit
f5d1684e33
  1. 11
      src/depositMoney.c

11
src/depositMoney.c

@ -1,8 +1,9 @@
#include "depositMoney.h"
#include "updateCustomerAccountBalance.c"
void askToTryAgain(bool afterError){
void askToTryAgain(bool afterError, int customerID){
char choice;
printf("\n");
if(afterError){
printf("Would you like to try again? [y] yes [n] no: ");
@ -12,7 +13,7 @@ void askToTryAgain(bool afterError){
scanf(" %c", &choice);
switch(choice){
case 'y':
depositMoney(1234,500);
depositMoney(customerID);
break;
case 'n':
break;
@ -33,7 +34,7 @@ bool depositMoney(int customerID){
//InitiateDepositMoney(amountToDeposit,availableAccountBalance);
if(updateAvailableAccountBalance(customerID, availableAccountBalance+amountToDeposit)==0){
printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit);
askToTryAgain(false);
askToTryAgain(false,customerID);
return true;
}else{
printf("Something went wrong. Please contact staff.");
@ -41,11 +42,11 @@ bool depositMoney(int customerID){
}
}else if(amountToDeposit>0){
printf("The amount you entered is lower than the minimum amount.");
askToTryAgain(true);
askToTryAgain(true,customerID);
return false; //amount lower than minimum deposit amount
}else{
printf("Invalid input.");
askToTryAgain(true);
askToTryAgain(true,customerID);
return false; //invalid input
}
return false;
Loading…
Cancel
Save