|
@ -1,4 +1,5 @@ |
|
|
#include "DepositMoney.h" |
|
|
|
|
|
|
|
|
#include "depositMoney.h" |
|
|
|
|
|
#include "updateCustomerAccountBalance.c" |
|
|
|
|
|
|
|
|
void AskToTryAgain(bool afterError){ |
|
|
void AskToTryAgain(bool afterError){ |
|
|
char choice; |
|
|
char choice; |
|
@ -11,32 +12,27 @@ void AskToTryAgain(bool afterError){ |
|
|
scanf(" %c", &choice); |
|
|
scanf(" %c", &choice); |
|
|
switch(choice){ |
|
|
switch(choice){ |
|
|
case 'y': |
|
|
case 'y': |
|
|
DepositMoney(); |
|
|
|
|
|
|
|
|
DepositMoney(1234,500); |
|
|
break; |
|
|
break; |
|
|
case 'n': |
|
|
case 'n': |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance){ //type of int to returnpossible end cases. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int DepositMoney(){ |
|
|
|
|
|
//TODO: Set a minimum deposit amount. |
|
|
|
|
|
float amountToDeposit; |
|
|
|
|
|
float availableAccountBalance = 10000; //for testing purposes. will be replaced with an actual function to retrieve this data. |
|
|
|
|
|
|
|
|
|
|
|
printf("\nPlease enter the amount to deposit: "); |
|
|
|
|
|
scanf("%f", &amountToDeposit); |
|
|
|
|
|
|
|
|
int DepositMoney(int customerID, float amountToDeposit){ |
|
|
|
|
|
float availableAccountBalance=getAvailableAccountBalance(customerID); |
|
|
|
|
|
|
|
|
if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ |
|
|
if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ |
|
|
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); |
|
|
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); |
|
|
printf("You have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); |
|
|
|
|
|
AskToTryAgain(false); |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
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){ |
|
|
}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); |
|
|
AskToTryAgain(true); |
|
@ -50,7 +46,5 @@ int DepositMoney(){ |
|
|
|
|
|
|
|
|
int main() |
|
|
int main() |
|
|
{ |
|
|
{ |
|
|
char any; |
|
|
|
|
|
DepositMoney(); |
|
|
|
|
|
scanf("%c", &any); |
|
|
|
|
|
|
|
|
DepositMoney(1234,500); |
|
|
} |
|
|
} |