diff --git a/src/sendmoney.c b/src/sendmoney.c index 393155d..848faa3 100644 --- a/src/sendmoney.c +++ b/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; } } diff --git a/src/sendmoney.h b/src/sendmoney.h index 31aeee1..e715643 100644 --- a/src/sendmoney.h +++ b/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