Browse Source

Implement showBalance and askToShowBalance

remotes/origin/feature/loan-eligibility
fdlt3817 2 years ago
parent
commit
5403c2b0a0
  1. 18
      src/sendmoney.c
  2. 1
      src/sendmoney.h

18
src/sendmoney.c

@ -9,12 +9,21 @@ void showBalance(int customerID){
printf(":.:.:.:.:.:\n"); printf(":.:.:.:.:.:\n");
} }
void askToShowBalance(int customerID){
char c;
printf("\nWould you like to see your remaining balance? [y] yes [any] no\n");
scanf(" %c",&c);
if(c=='y' || c=='Y'){
showBalance(customerID);
}
return;
}
bool sendMoney(int customerID){ bool sendMoney(int customerID){
float availableAccountBalance=getAvailableAccountBalance(customerID); float availableAccountBalance=getAvailableAccountBalance(customerID);
float amountToSend; float amountToSend;
int recID; int recID;
char c;
showBalance(customerID); showBalance(customerID);
printf("\nHow much would you like to send?\n"); printf("\nHow much would you like to send?\n");
scanf("%f",&amountToSend); scanf("%f",&amountToSend);
@ -32,6 +41,7 @@ bool sendMoney(int customerID){
if(withdrawSpecificAmount(customerID, amountToSend)){ if(withdrawSpecificAmount(customerID, amountToSend)){
if(depositSpecificAmount(recID, amountToSend)){ if(depositSpecificAmount(recID, amountToSend)){
printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID); printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID);
askToShowBalance(customerID);
return true; return true;
} }
else{ else{
@ -44,11 +54,7 @@ bool sendMoney(int customerID){
printf("\nThis ID is not from a customer of our bank. A transfer fee of %.2f€ will be taken.\n", TRANSFER_FEE); printf("\nThis ID is not from a customer of our bank. A transfer fee of %.2f€ will be taken.\n", TRANSFER_FEE);
if(withdrawSpecificAmount(customerID, amountToSend+TRANSFER_FEE)){ if(withdrawSpecificAmount(customerID, amountToSend+TRANSFER_FEE)){
printf("\nYou have successfuly transfered %.2f€ to [%d]\n",amountToSend,recID); printf("\nYou have successfuly transfered %.2f€ to [%d]\n",amountToSend,recID);
printf("\nWould you like to see your remaining balance? [y] yes [any] no\n");
scanf(" %c",&c);
if(c=='y' || c=='Y'){
showBalance(customerID);
}
askToShowBalance(customerID);
return true; return true;
} }
} }

1
src/sendmoney.h

@ -7,6 +7,7 @@
#define TRANSFER_FEE 0.8 #define TRANSFER_FEE 0.8
void showBalance(int customerID); void showBalance(int customerID);
void askToShowBalance(int customerID);
bool sendMoney(int customerID); bool sendMoney(int customerID);
#endif // SENDMONEY_H #endif // SENDMONEY_H
Loading…
Cancel
Save