|
@ -1,23 +1,17 @@ |
|
|
#include "withdrawMoney.h" |
|
|
#include "withdrawMoney.h" |
|
|
|
|
|
|
|
|
void initiateWithdraw(float amountToWithdraw, float availableAccountBalance) { |
|
|
|
|
|
char returnToHomeInput = NULL; |
|
|
|
|
|
float remainingAccountBalance = (availableAccountBalance - amountToWithdraw); |
|
|
|
|
|
|
|
|
float initiateWithdraw(float amountToWithdraw, float availableAccountBalance) { |
|
|
|
|
|
|
|
|
updateAccountBalance(remainingAccountBalance); |
|
|
|
|
|
printf("You have successfully withdrawn %f €.\n", amountToWithdraw); |
|
|
|
|
|
printf("Remaining account balance: %f €\n\n", remainingAccountBalance); |
|
|
|
|
|
printf("Press any key to return to home page: "); |
|
|
|
|
|
scanf("%c", &returnToHomeInput); |
|
|
|
|
|
|
|
|
float remainingAccountBalance = (availableAccountBalance - amountToWithdraw); |
|
|
|
|
|
|
|
|
if (returnToHomeInput) { |
|
|
|
|
|
showAllMenuEntries(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return remainingAccountBalance; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void withdraw(int user_id) { |
|
|
void withdraw(int user_id) { |
|
|
float amountToWithdraw; |
|
|
float amountToWithdraw; |
|
|
char tryDifferentAmount; |
|
|
char tryDifferentAmount; |
|
|
|
|
|
float remainingAccountBalance; |
|
|
|
|
|
bool updateSuccess = false; |
|
|
|
|
|
|
|
|
printf("Enter amount to withdraw: "); |
|
|
printf("Enter amount to withdraw: "); |
|
|
scanf("%f", &amountToWithdraw); |
|
|
scanf("%f", &amountToWithdraw); |
|
@ -25,7 +19,12 @@ void withdraw(int user_id) { |
|
|
float availableAccountBalance = getAvailableAccountBalance(user_id); |
|
|
float availableAccountBalance = getAvailableAccountBalance(user_id); |
|
|
if (amountToWithdraw > 0) { |
|
|
if (amountToWithdraw > 0) { |
|
|
if (amountToWithdraw <= availableAccountBalance) { |
|
|
if (amountToWithdraw <= availableAccountBalance) { |
|
|
initiateWithdraw(amountToWithdraw, availableAccountBalance); |
|
|
|
|
|
|
|
|
remainingAccountBalance = initiateWithdraw(amountToWithdraw, availableAccountBalance); |
|
|
|
|
|
updateSuccess = updateAccountBalance(user_id, remainingAccountBalance); |
|
|
|
|
|
if( updateSuccess ) { |
|
|
|
|
|
notifyCustomer(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
printf("You don't have sufficient money to withdraw. Do you want to try different amount?\n[y]: Yes, any other key : exit"); |
|
|
printf("You don't have sufficient money to withdraw. Do you want to try different amount?\n[y]: Yes, any other key : exit"); |
|
|