1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Stels [109]
3 years ago
13

Write a C program that will update a bank balance. A user cannot withdraw an amount ofmoney that is more than the current balanc

e. The current balance must always be non-negativevalue. 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.50Enter the transactions now.Enter an F for the transaction type when you are finished.Transaction Type (D=deposit, W=withdrawal, F=finished): DAmount: 568.34Transaction Type (D=deposit, W=withdrawal, F=finished): WAmount: 25.68Transaction Type (D=deposit, W=withdrawal, F=finished): WAmount: 167.40Transaction Type (D=deposit, W=withdrawal, F=finished): FYour ending balance is $1609.76Program is ending

Engineering
1 answer:
GarryVolchara [31]3 years ago
5 0

Answer:

Explanation:

Sample output:

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

Code to copy:

// include the necessary header files.

#include<stdio.h>

// Definition of the function

float withdraw(float account_balance, float withdraw_amount)

{

// Calculate the balace amount.

float balance_amount = account_balance - withdraw_amount;

// Check whether the withdraw amount

// is greater than 0 or not.

if (withdraw_amount > 0 && balance_amount >= 0)

{

// Assign value.

account_balance = balance_amount;

}

// return account_balance

return account_balance;

}

// Definition of the function deposit.

float deposit(float account_balance, float deposit_amount)

{

// Check whether the deposit amount is greater than zero

if (deposit_amount > 0)

{

// Update account balance.

account_balance = account_balance + deposit_amount;

}

// return account balance.

return account_balance;

}

int main()

{

// Declare the variables.

float account_balance;

float deposit_amount;

float withdrawl_amount;

char input;

// display the statement on console.

printf("BANK ACCOUT PROGRAM!\n");

printf("----------------------------------\n");

// prompt the user to enter the old balance.

printf("Enter the old balance: ");

// Input balance

scanf("%f", &account_balance);

// Display the statement on console.

printf("Enter the transactions now.\n");

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

// Start the do while loop

do

{

// prompt the user to enter transaction type.

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

// Input type.

scanf(" %c", &input);

// Check if the input is D

if (input == 'D')

{

// Prompt the user to input amount.

printf("Amount: ");

// input amount.

scanf("%f", &deposit_amount);

// Call to the function.

account_balance=deposit(account_balance,deposit_amount);

}

// Check if the input is W

if (input == 'W')

{

printf("Amount: ");

scanf("%f", &withdrawl_amount);

// Call to the function.

account_balance = withdraw(account_balance,withdrawl_amount);

}

// Check if the input is F

if (input == 'F')

{

// Dispplay the amount.

printf("Your ending balance is $%.2f\n", account_balance);

printf("Program is ending\n");

}

// End the while loop

} while(input != 'F');

return 0;

}

the picture uploaded below shows the program screenshot.

cheers, i hope this helps.

You might be interested in
After replacing a vacuum booster, the brakes lock up on a road test. Technician A says there is air trapped inside the brake lin
vitfil [10]

Answer:

Technician B

Explanation:

The brakes can lockup due to the following reasons

1) Overheating break systems

2) Use of wrong brake fluid

3) Broken or damaged drum brake backing plates, rotors, or calipers

4) A defective ABS part, or a defective parking mechanism or proportioning valve

5) Brake wheel cylinders, worn off

6) Misaligned power brake booster component

5 0
3 years ago
Explain Flags in ARM Processor​
kipiarov [429]

Answer:

The ARM processor normally contains at least the Z, N, C, and V flags, which are updated by execution of data processing instructions.

Explanation:

3 0
3 years ago
The maximum voltage in a cooling system should not exceed ______ volts.
Natali [406]

Answer:2%

When the voltages between the three phases are not equal, the current increases dramatically in the motor winding's, and if allowed to continue, the motor will be damaged.

Explanation:

7 0
2 years ago
Let S = { p q |p, q are prime numbers greater than 0} and E = {0, −2, 2, −4, 4, −6, 6, · · · } be the set of even integers. . Pr
Finger [1]

Answer:

prove that | S | = | E | ; every element of S there is an Image on E , while not every element on E has an image on S

Explanation:

Given that S = { p q |p, q are prime numbers greater than 0}

                    E = {0, −2, 2, −4, 4, −6, 6, · · · }

To prove  by constructing a bijection from S to E

detailed  solution attached below

After the bijection :

<em>prove that | S | = | E |</em> :  every element of S there is an Image on E , while not every element on E has an image on S

∴ we can say sets E and S are infinite sets

7 0
3 years ago
an inclined manometer is connected to a pitor tube to measure the velocity at the center of a circular duct. If the inclined man
jekas [21]
57.5 m/s
I did 2.3/0.04
I’m not sure if it’s correct though
8 0
3 years ago
Other questions:
  • Given the following MATLAB statement: ( 3 + 2 ) / 5 * 4 + 5 ^ 2 In what order will these operations be done?
    9·1 answer
  • To become familiar with the general equations of plane strain used for determining in-plane principal strain, maximum in-plane s
    9·1 answer
  • The component of a fluid system where a fluid is stored, but not under pressure, is called a container.
    5·1 answer
  • What is (10 to the power of three) times (3 to the power of 10)? will give brainliest
    13·1 answer
  • List everything wrong with 2020
    5·2 answers
  • A well is located in a 20.1-m thick confined aquifer with a conductivity of 14.9 m/day and a storativity of 0.0051. If the well
    5·1 answer
  • 3. What type of tool do you use to make angles?
    15·1 answer
  • A hub a signal that refreshes the signal strength.
    5·1 answer
  • The coefficient of static friction for both wedge surfaces is μw=0.4 and that between the 27-kg concrete block and the β=20° inc
    6·1 answer
  • I am trying to make a vacuum cannon but all I can use to get out the air is a speed pump to give air to bicycles. I need to make
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!