Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 ");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote