diff --git a/src/.vscode/c_cpp_properties.json b/src/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..5a5047e --- /dev/null +++ b/src/.vscode/c_cpp_properties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.19041.0", + "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/src/depositMoney.c b/src/depositMoney.c new file mode 100644 index 0000000..50f5b3e --- /dev/null +++ b/src/depositMoney.c @@ -0,0 +1,50 @@ +#include "depositMoney.h" +#include "updateCustomerAccountBalance.c" + +void AskToTryAgain(bool afterError){ + char choice; + printf("\n"); + if(afterError){ + printf("Would you like to try again? [y] yes [n] no: "); + }else{ + printf("Would you like to make another deposit? [y] yes [n] no: "); + } + scanf(" %c", &choice); + switch(choice){ + case 'y': + DepositMoney(1234,500); + break; + case 'n': + break; + } + +} + +int DepositMoney(int customerID, float amountToDeposit){ + float availableAccountBalance=getAvailableAccountBalance(customerID); + + if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ + //InitiateDepositMoney(amountToDeposit,availableAccountBalance); + if(updateAvailableAccountBalance(customerID, amountToDeposit, true)==0){ + printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); + AskToTryAgain(false); + return 0; + }else{ + printf("Something went wrong. Please contact staff."); + return 3; + } + }else if(amountToDeposit>0){ + printf("The amount you entered is lower than the minimum amount."); + AskToTryAgain(true); + return 1; //amount lower than minimum deposit amount + }else{ + printf("Invalid input."); + AskToTryAgain(true); + return 2; //invalid input + } +} + +int main() +{ + DepositMoney(1234,500); +} diff --git a/src/depositMoney.h b/src/depositMoney.h new file mode 100644 index 0000000..306aaab --- /dev/null +++ b/src/depositMoney.h @@ -0,0 +1,9 @@ +#include +#include "CustomerProperties.h" +#include +#define MINIMUM_DEPOSIT_AMOUNT 5 + + +int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance); +int DepositMoney(int customerID, float amountToDeposit); +void AskToTryAgain(bool afterError); diff --git a/src/main.c b/src/main.c index 3e233a1..db4aea3 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,7 @@ #include -#include"mainMenu.h" int main() { - ageInput(); - return 0; -} + + return 0; +}