Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating two non trivial functions in c programming using the code below. #include main(void) { int num_deposit = 0, i, s; int

I need help creating two non trivial functions in c programming using the code below.

#include

main(void)

{

int num_deposit = 0, i, s;

int num_withdrawal = 0;

float current_balance;

float ending_balance;

float total_deposit = 0;

float deposit[5];

float withdrawals[5];

printf("Welcome to the Computer Banking System ");

printf("Enter your current balance in dollars and cents: ");

scanf("%f", ¤t_balance);

printf(" ");

while(current_balance < 0)

{

printf("*** Beginning balance must be at least zero, please re-enter.");

scanf("%f", ¤t_balance);

}

printf("Enter the number of deposits (0-5): ");

scanf("%d", &num_deposit);

while(num_deposit < 0||num_deposit>5)

{

printf("*** Invalid number of deposits, please re-enter. ");

printf("Enter the number of deposits: ");

scanf("%d", &num_deposit);

}

printf(" Enter the number of withdrawals (0-5): ");

scanf("%d", &num_withdrawal);

printf(" ");

while(num_withdrawal < 0||num_withdrawal>5)

{

printf(" *** Invalid number of withdrawals, please re-enter.");

printf("Enter the number of withdrawals: ");

scanf("%d", &num_withdrawal);

}

for(i = 0; i < num_deposit; i++)

{

printf("Enter the amount of deposit #%d: ", i+1);

scanf("%f", &deposit[i]);

while(deposit[i]<0)

{

printf("*** Deposit amount must be greater than zero, please re-enter. ");

printf(" Enter the amount of deposit #%d: ", i+1);

scanf("%f", &deposit[i]);

}

total_deposit+=deposit[i];

}

printf(" ");

for(i = 0; i < num_withdrawal; i++)

{

printf("Enter the amount of withdrawal #%d: ", i+1);

scanf("%f", &withdrawals[i]);

while(withdrawals[i]<0)

{

printf("withdrawal amount must be greater than 0 ");

printf("please re-enter. ");

printf(" Enter the amount of withdrawal #%d: ", i+1);

scanf("%f", &withdrawals[i]);

}

if(withdrawals[i]>(current_balance+total_deposit))

{

printf("*** Withdrawal amount exceeds current balance, please re-enter *** ");

i--;

}

else

total_deposit -=withdrawals[i];

}

ending_balance= current_balance+total_deposit;

printf(" ");

printf("The closing balance is %.2f ",ending_balance);

if(ending_balance>=50000.00)

printf("*** it is time to invest some money*** ");

else if(ending_balance>=15000.00)

printf("*** maybe you should consider a CD. *** ");

else if(ending_balance>=1000.00)

printf("*** keep up the good work. *** ");

else if(ending_balance>=0)

printf("*** your balance getting low. *** ");

printf(" ");

printf("***** Bank Record ****** ");

printf("Starting Balance $%.2f ",current_balance);

for(i = 0; i < num_deposit; i++)

{

printf("Deposit #%d : $%.2f ",i+1,deposit[i]);

}

printf(" ");

for(i = 0; i < num_withdrawal; i++)

{

printf("Withdrawal #%d : $%.2f ",i+1,withdrawals[i]);

}

printf(" ");

printf("Ending balance :$%.2f ",ending_balance);

printf(" ");

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

=+ 3. Suppose an economy is in long-run equilibrium.

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago