Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!