diff --git a/src/withdrawMoney.c b/src/withdrawMoney.c new file mode 100644 index 0000000..dc3a2e9 --- /dev/null +++ b/src/withdrawMoney.c @@ -0,0 +1,30 @@ +#include + +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(); + } +} \ No newline at end of file