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

Write a C program that will update a bank balance. A user cannot withdraw an amo

ID: 3781044 • Letter: W

Question

Write a C program that will update a bank balance. A user cannot withdraw an amount of money that is more than the current balance. The current balance must always be non-negative value. The variable types must be selected wisely.

A sample run is below. The user’s response is in boldface (C by discovery)

BANK ACCOUT PROGRAM!

----------------------------------

Enter the old balance: 1234.50

Enter the transactions now.

Enter an F for the transaction type when you are finished.

Transaction Type (D=deposit, W=withdrawal, F=finished): D

Amount: 568.34

Transaction Type (D=deposit, W=withdrawal, F=finished): W

Amount: 25.68

Transaction Type (D=deposit, W=withdrawal, F=finished): W

Amount: 167.40

Transaction Type (D=deposit, W=withdrawal, F=finished): F

Your ending balance is $1609.76

Program is ending

Please type the code for me use the C language.

Explanation / Answer

#include<stdio.h>

float withdraw(float account_balance, float withdraw_amount)
{   
float balance_amount = account_balance - withdraw_amount;

if (withdraw_amount > 0 && balance_amount >= 0)
{
account_balance = balance_amount;
}
return account_balance;
}

float deposit(float account_balance, float deposit_amount)
{
if (deposit_amount > 0)
{
account_balance = account_balance + deposit_amount;
}
return account_balance;
}

int main()
{
printf("BANK ACCOUT PROGRAM! ");
printf("---------------------------------- ");
printf("Enter the old balance: ");
float account_balance;
scanf("%f", &account_balance);

printf("Enter the transactions now. ");

printf("Enter an F for the transaction type when you are finished. ");

char input;

do
{
printf("Transaction Type (D=deposit, W=withdrawal, F=finished): ");
scanf(" %c", &input);
if (input == 'D')
{
float deposit_amount;
printf("Amount: ");
scanf("%f", &deposit_amount);
account_balance=deposit(account_balance,deposit_amount);
}
if (input == 'W')
{
float withdrawl_amount;
printf("Amount: ");

scanf("%f", &withdrawl_amount);
account_balance = withdraw(account_balance,withdrawl_amount);
}
if (input == 'F')
{
printf("Your ending balance is $%.2f ", account_balance);
printf("Program is ending ");
}

} while(input != 'F');

return 0;
}

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