Browse Source

Create show balance function

remotes/origin/feature/loan-eligibility
fdlt3817 2 years ago
parent
commit
4b96f96df8
  1. 22
      src/sendmoney.c
  2. 2
      src/sendmoney.h

22
src/sendmoney.c

@ -2,11 +2,21 @@
#include "depositMoney.c" #include "depositMoney.c"
#include "withdrawMoney.c" #include "withdrawMoney.c"
void showBalance(int customerID){
float balance=getAvailableAccountBalance(customerID);
printf("\n:.:.:.:.:.:");
printf("\nYour current balance is %.2f.\n",balance);
printf(":.:.:.:.:.:\n");
}
bool sendMoney(int customerID){ bool sendMoney(int customerID){
float availableAccountBalance=getAvailableAccountBalance(customerID); float availableAccountBalance=getAvailableAccountBalance(customerID);
float amountToSend; float amountToSend;
int recID; int recID;
printf("\nYou have %.2f€ in your account. How much would you like to send?\n",availableAccountBalance);
char c;
showBalance(customerID);
printf("\nHow much would you like to send?\n");
scanf("%f",&amountToSend); scanf("%f",&amountToSend);
if(amountToSend>0 && amountToSend<availableAccountBalance){ if(amountToSend>0 && amountToSend<availableAccountBalance){
printf("\nYour input was %.2f€. Please enter the recipient id.\n",amountToSend); printf("\nYour input was %.2f€. Please enter the recipient id.\n",amountToSend);
@ -31,8 +41,14 @@ bool sendMoney(int customerID){
} }
}else{ }else{
if(withdrawSpecificAmount(customerID, amountToSend)){
printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID);
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);
}
return true; return true;
} }
} }

2
src/sendmoney.h

@ -5,6 +5,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#define TRANSFER_FEE 0.8
void showBalance(int customerID);
bool sendMoney(int customerID); bool sendMoney(int customerID);
#endif // SENDMONEY_H #endif // SENDMONEY_H
Loading…
Cancel
Save