Create an ATM machine to withdraw deposit and check balances of a bank account.
ID: 3552131 • Letter: C
Question
Create an ATM machine to withdraw deposit and check balances of a bank account.
This function is supposed to withdraw a desired amount from the chosen account. I'm having problems updating the balance of the accounts after withdrawing money.
void WithdrawMoney( double *currBal, char typeAcct)
{
double withdrawal=0;
double savings = 3750.00;
double checking = 575.00;
double credit = -450.00;
printf("How much would you like to withdraw? ");
scanf(" %f", withdrawal);
if(typeAcct == 'C')
{
*currBal = checking-withdrawal;
}
else if(typeAcct == 'S')
{
*currBal = savings-withdrawal;
}
else if(typeAcct == 'R')
{
*currBal = credit-withdrawal;
}
printf("Thank you, please take your cash and receipt ");
}
Explanation / Answer
void WithdrawMoney( double *currBal, char typeAcct)
{
double withdrawal=0;
double savings = 3750.00;
double checking = 575.00;
double credit = -450.00;
printf("How much would you like to withdraw? ");
scanf("%lf", &withdrawal); // here u have to provide the address bug is in this line. updated code.
if(typeAcct == 'C')
{
*currBal = checking-withdrawal;
}
else if(typeAcct == 'S')
{
*currBal = savings-withdrawal;
}
else if(typeAcct == 'R')
{
*currBal = credit-withdrawal;
}
printf("Thank you, please take your cash and receipt ");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.