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