|
@ -1,9 +1,26 @@ |
|
|
#include "depositMoney.h" |
|
|
|
|
|
|
|
|
#include "DepositMoney.h" |
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'n': |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance){ //type of int to returnpossible end cases. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance){ //type of int to return possible end cases. |
|
|
|
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -12,15 +29,22 @@ int DepositMoney(){ |
|
|
float amountToDeposit; |
|
|
float amountToDeposit; |
|
|
float availableAccountBalance = 10000; //for testing purposes. will be replaced with an actual function to retrieve this data. |
|
|
float availableAccountBalance = 10000; //for testing purposes. will be replaced with an actual function to retrieve this data. |
|
|
|
|
|
|
|
|
printf("Please enter the amount to deposit: "); |
|
|
|
|
|
|
|
|
printf("\nPlease enter the amount to deposit: "); |
|
|
scanf("%f", &amountToDeposit); |
|
|
scanf("%f", &amountToDeposit); |
|
|
|
|
|
|
|
|
if(amountToDeposit>0){ |
|
|
|
|
|
|
|
|
if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ |
|
|
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); |
|
|
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); |
|
|
printf("You have successfully deposited %f. New account balance is %f", amountToDeposit, availableAccountBalance+amountToDeposit); |
|
|
|
|
|
|
|
|
printf("You have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); |
|
|
|
|
|
AskToTryAgain(false); |
|
|
return 0; |
|
|
return 0; |
|
|
|
|
|
}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{ |
|
|
}else{ |
|
|
return 1; //invalid input |
|
|
|
|
|
|
|
|
printf("Invalid input."); |
|
|
|
|
|
AskToTryAgain(true); |
|
|
|
|
|
return 2; //invalid input |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|