Browse Source

Create withdrawMoney.c to implement 'withdraw' function

remotes/origin/feature/withdraw-money-system
Shivam Chaudhary 2 years ago
parent
commit
48b95447a1
  1. 30
      src/withdrawMoney.c

30
src/withdrawMoney.c

@ -0,0 +1,30 @@
#include <stdio.h>
void withdraw() {
float amountToWithdraw;
char tryDifferentAmount;
float availableAccountBalance = getAvailableAccountBalance();
printf("Enter amount to withdraw: ");
scanf("%f", &amountToWithdraw);
if (amountToWithdraw > 0) {
if (amountToWithdraw <= availableAccountBalance) {
initiateWithdraw(amountToWithdraw, availableAccountBalance);
}
else {
printf("You don't have sufficient money to withdraw. Do you want to try different amount?\n[y]: Yes, any other key : exit");
scanf(" %c", &tryDifferentAmount);
if (tryDifferentAmount == 'Y' || tryDifferentAmount == 'y') {
withdraw();
}
else {
// return to home page
}
}
}
else {
printf("Invalid Input! Please try again.\n");
withdraw();
}
}
Loading…
Cancel
Save