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
The density of a certain type of steel is 8.1 g/cm3. What is the mass of a 100 cm3 chunk of this steel
irina1246 [14]

Answer:

  810 g

Explanation:

Mass is the product of density and volume:

  m = ρV

  m = (8.1 g/cm³)(100 cm³) = 810 g

The mass of the chunk is 810 grams.

4 0
2 years ago
This problem demonstrates aliasing. Generate a 512-point waveform consisting of 2 sinusoids at 200 and 400-Hz. Assume a sampling
aalyn [17]

Answer and Explanation:

clear all; close all;  

N=512;  

t=(1:N)/N;

fs=1000;  

f=(1:N)*fs/N;

x= sin(2*pi*200*t) + sin(2*pi*400*t);  

y= sin(2*pi*200*t) + sin(2*pi*900*t);

for n = 1:20  

a(n) = (2/N)*sum(x.*(cos(2*pi*n*t)))

b(n) = (2/N)*sum(x.*(sin(2*pi*n*t)))  

c(n) = sqrt(a(n).^2+b(n).^2)  

theta(n) =-(360/(2*pi))*atan(b(n)./a(n));  

end  

plot(f(1:20),c(1:20),'rd');

disp([a(1:4),b(1:4),c(1:4),theta(1:4)])

8 0
3 years ago
g Consider a thin opaque, horizontal plate with an electrical heater on its backside. The front end is exposed to ambient air th
xxTIMURxx [149]

Answer:

The electrical power is 96.5 W/m^2

Explanation:

The energy balance is:

Ein-Eout=0

qe+\alpha sGs+\alpha skyGsky-EEb(Ts)-qc=0

if:

Gsky=oTsky^4

Eb=oTs^4

qc=h(Ts-Tα)

\alpha s=\frac{\int\limits^\alpha _0 {\alpha l Gl} \, dl }{\int\limits^\alpha _0 {Gl} \, dl }

\alpha s=\frac{\int\limits^\alpha _0 {\alpha lEl(l,5800 } \, dl }{\int\limits^\alpha _0 {El(l,5800)} \, dl }

if Gl≈El(l,5800)

\alpha s=(1-0.2)F(0-2)+(1-0.7)(1-F(0-2))

lt= 2*5800=11600 um-K, at this value, F=0.941

\alpha s=(0.8*0.941)+0.3(1-0.941)=0.77

The hemispherical emissivity is equal to:

E=(1-0.2)F(0-2)+(1-0.7)(1-F(0-2))

lt=2*333=666 K, at this value, F=0

E=0+(1-0.7)(1)=0.3

The hemispherical absorptivity is equal to:

qe=EoTs^{4}+h(Ts-T\alpha  )-\alpha sGs-\alpha oTsky^{4}=(0.3*5.67x10^{-8}*333^{4})+10(60-20)-(0.77-600)-(0.3*5.67x10^{-8}*233^{4})=96.5 W/m^{2}

3 0
3 years ago
PELASEE HELPPP WITH MARK BRAINLIST!!!! You are stopped at a red light, and a long string of cars is crossing in front of you. Wh
choli [55]

Answer:

1st one.

Explanation:

I think that because they the one who is going to get a ticket and also you will not gonna get in a car accident.

7 0
3 years ago
Read 2 more answers
A rigid tank contains 1 kg of oxygen (O2) at p1 = 35 bar, T1 = 180 K. The gas is cooled until the temperature drops to 150 K. De
andreyandreev [35.5K]

Answer:

a. Volume = 13.36 x 10^-3 m³ Pressure = 29.17 bar  b. Volume = 14.06 x 10^-3 m³ Pressure = 22.5 bar

Explanation:

Mass of O₂ = 1kg, Pressure (P1) = 35bar, T1= 180K, T2= 150k Molecular weight of O₂ = 32kg/Kmol

Volume of tank and final pressure using a)Ideal Gas Equation and b) Redlich - Kwong Equation

a. PV=mRT

V = {1 x (8314/32) x 180}/(35 x 10⁵) = 13.36 x 10^-3

Since it is a rigid tank the volume of the tank must remain constant and hnece we can say

T2/T1 = P2/P1, solving for P2

P2 = (150/180) x 35 = 29.17bar

b. P1 = {RT1/(v1-b)} - {a/v1(v1+b)(√T1)}

where R, a and b are constants with the values of, R = 0.08314bar.m³/kmol.K, a = 17.22(m³/kmol)√k, b = 0.02197m³/kmol

solving for v1

35 = {(0.08314 x 180)/(v1 - 0.02197)} - {17.22/(v1)(v1 + 0.02197)(√180)}

35 = {14.96542/(v1-0.02197)} - {1.2835/v1(v1 + 0.02197)}

Using Trial method to find v1

for v1 = 0.5

Right hand side becomes =  {14.96542/(0.5-0.02197)} - {1.2835/0.5(0.5 + 0.02197)} = 31.30 ≠ Left hand side

for v1 = 0.4

Right hand side becomes =  {14.96542/(0.4-0.02197)} - {1.2835/0.4(0.4 + 0.02197)} = 39.58 ≠ Left hand side

for v1 = 0.45

Right hand side becomes =  {14.96542/(0.45-0.02197)} - {1.2835/0.45(0.45 + 0.02197)} = 34.96 ≅ 35

Specific Volume = 35 m³/kmol

V = m x Vspecific/M = (1 x 0.45)/32 = 14.06 x 10^-3 m³

For Pressure P2, we know that v2= v1

P2 = {RT2/(v2-b)} - {a/v2(v2+b)(√T2)} = {(0.08314 x 150)/(0.45 - 0.02197)} - {17.22/(0.45)(0.45 + 0.02197)(√150)} = 22.5 bar

3 0
3 years ago
Other questions:
  • Practicing new things strains your brain fibers, weakening your ability to make connections.
    13·1 answer
  • An inflatable structure has the shape of a half-circular cylinder with hemispherical ends. The structure has a radius of 40 ft w
    6·1 answer
  • Which pendulum will.mobe faster​
    13·1 answer
  • The natural variation of a process relative to the variation allowed by the design specifications is known as
    15·1 answer
  • A cylindrical bar of steel 10.1 mm (0.3976 in.) in diameter is to be deformed elastically by application of a force along the ba
    15·1 answer
  • A milling operation was used to remove a portion of a solid bar of square cross section. Forces of magnitude P = 18 kN are appli
    15·1 answer
  • A receptacle, plug, or any other electrical device whose design limits the ability of an electrician to come in contact with any
    14·1 answer
  • The outer surface of a spacecraft in space has an emissivity of 0.6 and an absorptivity of 0.2 for solar radiation. If solar rad
    12·1 answer
  • Assess the capabilities of a hydroelectric power plant from the following field data: Estimated water flow rate, 40 m3/s River i
    9·1 answer
  • 4 Error-Correcting Polynomials (a) Alice has a length 8 message to Bob. There are 2 communication channels available. When n pac
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!