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
Problem 1: A catchment has the following Horton’s infiltration parameters: f0=280 mm/hr, fc=25 mm/hr and k = 2.5 hr-1 . For the
harkovskaia [24]

Answer:

Ponding will occur in 40mins

Explanation:

We say that the infiltration rate is the velocity or speed at which water enters into the soil. This often times is measured by the depth (in mm) of the water layer that can enter the soil in one hour. An infiltration rate of 15 mm/hour means that a water layer of 15 mm on the soil surface, will take one hour to infiltrate.

Consider checking attachment for the step by step solution.

6 0
3 years ago
A three-point bending test is performed on a glass specimen having a rectangular cross section of height d = 5.4 mm (0.21 in.) a
Fudgin [204]

Answer:

5.21e-2mm

Explanation:

Please see attachment

8 0
3 years ago
Which of the following has led to a safer and more prosperous global community within the last century? the Bronze Age composite
sattari [20]

Answer:

The bronze age

4 0
3 years ago
Read 2 more answers
Two vertical, parallel clean glass plates are spaced a distance of 2mm apart. if the plates are placed in water, how high will t
Ulleksa [173]

Answer with Explanation:

The capillary rise in 2 parallel plates immersed in a liquid is given by the formula

h=\frac{2\sigma cos(\alpha )}{\rho gd}

where

\sigma is the surface tension of the liquid

\alpha is the contact angle of the liquid

\rho is density of liquid

'g' is acceleratioj due to gravity

'd' is seperation between thje plates

Part a) When the liquid is water:

For water and glass we have

\sigma =7.28\times 10^{-2}N/m

\alpha =0

\rho _{w}=1000kg/m^3

Applying the values we get

h=\frac{2\times 7.28\times 10^{-2}cos(0)}{1000\times 9.81\times 2\times 10^{-3}}=7.39mm

Part b) When the liquid is mercury:

For mercury and glass we have

\sigma =485.5\times 10^{-3}N/m

\alpha =138^o

\rho _{w}=13.6\times 10^{3}kg/m^3

Applying the values we get

h=\frac{2\times 485.5\times 10^{-3}cos(138)}{13.6\times 1000\times 9.81\times 2\times 10^{-3}}=-2.704mm

The negative sign indicates that there is depression in mercury in the tube.

4 0
3 years ago
Can i eat unhealthy while i’m drinking green tea for weight loss ?
Zina [86]

Answer:I don't think it's a better idea to eat unhealthy food while having green tea because it will act as a strumbling rock in your attempt of getting weight loss.

Explanation:I don't say you have to mark my ans as brainliest but if ypu think it has really helped you plz don't forget to thank me...

6 0
3 years ago
Read 2 more answers
Other questions:
  • If a building is too humid, what harmful substance may be stored there?
    13·2 answers
  • What is the formula for measuring the speed of an object
    14·1 answer
  • Unit for trigonometric functions is always "radian". 1. 10 points: Do NOT submit your MATLAB code for this problem (a) Given f(x
    9·1 answer
  • Input signal to a controller is​
    9·1 answer
  • If 65 gallons of hydraulic oil weighs 350lb, what is the specific weight of the oil in lb/ft^3?
    14·1 answer
  • The Bureau of Labor and Statistics predicted that the field of biomedical engineering would increase by 62 percent over the comi
    5·1 answer
  • Build a 32-bit accumulator circuit. The circuit features a control signal inc and enable input en. If en is 1 and inc is 1, the
    13·1 answer
  • Water at 70 kPa and 1008C is compressed isentropically in a closed system to 4 MPa. Determine the final temperature of the water
    6·1 answer
  • What is a radio wave made up of? Molecules? Electrons? Other?
    15·2 answers
  • Describe two fundamental reasons why flexural strength should depend on porosity
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!