|
|
@ -23,37 +23,39 @@ void askToTryAgain(bool afterError, int customerID){ |
|
|
|
} |
|
|
|
|
|
|
|
bool depositMoney(int customerID){ |
|
|
|
|
|
|
|
float availableAccountBalance=getAvailableAccountBalance(customerID); |
|
|
|
if(availableAccountBalance<0){ |
|
|
|
printf("\nCould not retreive account balance. Please contact staff.\n"); |
|
|
|
float availableAccountBalance = getAvailableAccountBalance(customerID); |
|
|
|
if (availableAccountBalance < 0) { |
|
|
|
printf("\nCould not retrieve account balance. Please contact staff.\n"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
float amountToDeposit = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("\nPlease enter the amount you want to deposit: "); |
|
|
|
float amountToDeposit = 0; |
|
|
|
scanf("%f", &amountToDeposit); |
|
|
|
|
|
|
|
if(amountToDeposit>=0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ |
|
|
|
if(updateAvailableAccountBalance(customerID, availableAccountBalance+amountToDeposit)){ |
|
|
|
printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); |
|
|
|
askToTryAgain(false,customerID); |
|
|
|
return true; |
|
|
|
}else{ |
|
|
|
printf("Something went wrong. Please contact staff."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}else if(amountToDeposit>0){ |
|
|
|
printf("The amount you entered is lower than the minimum amount."); |
|
|
|
askToTryAgain(true,customerID); |
|
|
|
return false; //amount lower than minimum deposit amount |
|
|
|
}else{ |
|
|
|
if (amountToDeposit < 0) { |
|
|
|
printf("Invalid input."); |
|
|
|
askToTryAgain(true,customerID); |
|
|
|
return false; //invalid input |
|
|
|
askToTryAgain(true, customerID); |
|
|
|
return false; |
|
|
|
} |
|
|
|
else if (amountToDeposit < MINIMUM_DEPOSIT_AMOUNT) { |
|
|
|
printf("The amount you entered is lower than the minimum amount."); |
|
|
|
askToTryAgain(true, customerID); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (updateAvailableAccountBalance(customerID, availableAccountBalance + amountToDeposit)) { |
|
|
|
printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance + amountToDeposit); |
|
|
|
askToTryAgain(false, customerID); |
|
|
|
return true; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Something went wrong. Please contact staff."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool depositSpecificAmount(int customerID, float amount){ |
|
|
|
|
|
|
|
float availableAccountBalance=getAvailableAccountBalance(customerID); |
|
|
@ -74,4 +76,4 @@ int main(){ |
|
|
|
//depositMoney(1234); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
*/ |
|
|
|
*/ |