From 30e1fcfa9e4f4c991f230260a41b5e2ef3b396dc Mon Sep 17 00:00:00 2001 From: Shivam Chaudhary Date: Sat, 28 Jan 2023 12:26:54 +0100 Subject: [PATCH] Refactoring: organize code to skip bad behavior --- src/withdrawMoney.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/withdrawMoney.c b/src/withdrawMoney.c index 130a49a..b3165d0 100644 --- a/src/withdrawMoney.c +++ b/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); }