Browse Source

Refactoring: organize code to skip bad behavior

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

6
src/withdrawMoney.c

@ -19,17 +19,17 @@ void withdraw(int user_id) {
float amountToWithdraw;
char tryDifferentAmount;
float availableAccountBalance = getAvailableAccountBalance(user_id);
printf("Enter amount to withdraw: ");
scanf("%f", &amountToWithdraw);
float availableAccountBalance = getAvailableAccountBalance(user_id);
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);
scanf("%c", &tryDifferentAmount);
if (tryDifferentAmount == 'Y' || tryDifferentAmount == 'y') {
withdraw(user_id);
}

Loading…
Cancel
Save