|
@ -1,9 +1,26 @@ |
|
|
#include "depositMoney.h" |
|
|
|
|
|
|
|
|
#include "DepositMoney.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance){ //type of int to return possible end cases. |
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -11,16 +28,23 @@ int DepositMoney(){ |
|
|
//TODO: Set a minimum deposit amount. |
|
|
//TODO: Set a minimum deposit amount. |
|
|
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 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -29,4 +53,4 @@ int main() |
|
|
char any; |
|
|
char any; |
|
|
DepositMoney(); |
|
|
DepositMoney(); |
|
|
scanf("%c", &any); |
|
|
scanf("%c", &any); |
|
|
} |
|
|
|
|
|
|
|
|
} |