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");
}
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){
float availableAccountBalance=getAvailableAccountBalance(customerID);
float amountToSend;
int recID;
char c;
showBalance(customerID);
printf("\nHow much would you like to send?\n");
scanf("%f",&amountToSend);
@ -32,6 +41,7 @@ bool sendMoney(int customerID){
if(withdrawSpecificAmount(customerID, amountToSend)){
if(depositSpecificAmount(recID, amountToSend)){
printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID);
askToShowBalance(customerID);
return true;
}
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);
if(withdrawSpecificAmount(customerID, amountToSend+TRANSFER_FEE)){
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;
}
}

1
src/sendmoney.h

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