Question: Please refer to code after prompt that is the assignment 4 that is mentioned. PROGRAMMING ASSIGNMENT #5 This program is similar to programming assignment #4.

Please refer to code after prompt that is the assignment 4 that is mentioned. PROGRAMMING ASSIGNMENT #5 This program is similar to programming assignment #4. That is, you will have all of the requirements as in Programming Assignment #4, including data error checking on all inputs. Your program is to behave in the exact same manner as assignment #4, however how you structure your code is a different story. Now we will use functions. Recall Programming Assignment #4: Write a C program that allows the user to make some simple banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents, not less than zero). The program should then prompt the user to enter the number of withdrawals to make, and then the number of deposits to make. For this assignment, let's set a maximum of 5 deposits and 5 withdrawals (etc.) Here is the change for program #5: There should be at least two non-trivial functions in the program. (Non-trivial means that the function does more than simply print a line of text.) Here are some examples of what you might want to use for your functions: Input functions: 1. Obtain opening (current) balance. 2. Obtain number the number of deposits. 3. Obtain number of withdrawals. 4. Obtain deposit amounts. 5. Obtain withdrawal amounts. Output functions: 1. Display closing balance and associated message. 2. Display message based on closing balance. 3. Display bank record. Hints: Your code from assignment #4 does not need to be modified too much to solve this problem. The algorithm is the same. Outputting the contents of the arrays in "record form" is pretty straightforward, and should be done in a loop. (This could be a good place for a function.) The most complicated of the above functions is the one which would display the bank record. If you decide that you want to attempt this one, I will give you a head start by providing the function header as shown here: void (display_bank_record (float start_balance, float deposits [ ], int num_deposits, float withdrawals [ ], int num_withdrawals, float end_balance) Good luck!

This is assignment 4 please use this to answer prompt above. There must be 2 non trivial variables

#include

int main(void)

{ /* Variable Declarations */ /* --------------------- */ int number_of_deposits = 0, number_of_withdrawals = 0, i = 0; float beginning_balance, closing_balance, deposit_total = 0; float deposit_amount[5], withdrawl_amount[5];

/* Instructional message placed outside of loop */ /* -------------------------------------------- */ printf("Welcome to the Computer Banking System "); printf("Enter your current balance in dollars and cents: "); scanf("%f", &beginning_balance);

/* If beginning balance is less than zero then display */ /* error message to prompt user to reenter their input */ /* ---------------------------------------------------- */

while (beginning_balance < 0) { printf("*** Beginning balance must be at least zero, please re-enter."); scanf("%f", &beginning_balance); }

printf("Enter the number of deposits (0 - 5): "); scanf("%d", &number_of_deposits);

/* If number of deposits is less than zero or greater than 5 */ /* Error message to prompt user to reenter their input */ /* ------------------------------------------------------- */

while (number_of_deposits < 0 || number_of_deposits > 5) { printf(" *** Invalid number of deposits, please re-enter."); scanf("%d", &number_of_deposits); }

printf("Enter the number of withdrawals (0 - 5): "); scanf("%d", &number_of_withdrawals);

/* If withdrawal amount exceeds the current balance */ /* error message to prompt user to reenter their input */ /* ---------------------------------------------------- */

while (number_of_withdrawals < 0 || number_of_withdrawals > 5) { printf("*** Withdrawal amount exceeds current balance, please re-enter. "); scanf("%d", &number_of_withdrawals); }

/* Read in amount of each deposit inputed by user */ /* --------------------------------------------- */

for (i = 0; i < number_of_deposits; i++) { printf("Enter the amount of deposit #%d: ", i + 1); scanf("%f", &deposit_amount[i]);

/* If deposit amount is a negative number then have an */ /* error message to prompt user to reenter their input */ /* -------------------------------------------------- */

while (deposit_amount[i] < 0) { printf("deposit amount must be at least zero "); printf("please re-enter. "); scanf("%f", &deposit_amount[i]); }

/* Add input of all deposits to calculate total */ /* --------------------------------------------- */

deposit_total += deposit_amount[i]; }

/* Read in amount of each withdrawl inputed by user */ /* ----------------------------------------------- */

for (i = 0; i < number_of_withdrawals; i++) { printf("Enter the amount of withdrawal #%d: ", i + 1); scanf("%f", &withdrawl_amount[i]);

/* If withdrawal amount is a negative number then have */ /* error message to prompt user to reenter their input */ /* -------------------------------------------------- */

while (withdrawl_amount[i] < 0) { printf("***Withdrawal amount must be at least zero "); printf("please re-enter. "); printf("Enter the amount of withdrawal #%d: ", i + 1); scanf("%f", &withdrawl_amount[i]); }

/* If withdrawal amount is more than current balance plus */ /* deposit total then prompt user to reenter their input */ /* ---------------------------------------------------- */

if (withdrawl_amount[i] > (beginning_balance + deposit_total)) { printf("*** Withdrawal amount exceeds current balance. please re-enter "); i--; }

/* Takes out withdrawal from the deposit total */ /* ------------------------------------------ */ else deposit_total -= withdrawl_amount[i]; }

/* Calculate closing balance then display output */ /* -------------------------------------------- */

closing_balance = beginning_balance + deposit_total;

/* Dialoge output based on closing balance amount */ /* -------------------------------------------- */

printf(" The closing balance is %.2f ", closing_balance); if (closing_balance >= 50000) printf("*** It is time to invest some money! *** "); else if (closing_balance >= 15000) printf("*** Maybe you should consider a CD. *** "); else if (closing_balance >= 1000) printf("*** Keep up the good work! *** "); else if (closing_balance >= 0) printf("*** Your balance is getting low! *** ");

/* Display final bank record output for user */ /* ---------------------------------------- */

printf("*** Bank Record *** "); printf(" Starting Balance: $%.2f ", beginning_balance);

for (i = 0; i < number_of_deposits; i++) { printf("Deposit #%d: %.2f ", i + 1, deposit_amount[i]); } printf(" "); for (i = 0; i < number_of_withdrawals; i++) { printf("Withdrawal #%d: %.2f ", i + 1, withdrawl_amount[i]); } printf(" "); printf("Ending balance: $%.2f ", closing_balance); printf(" ");

/* The following is used to pause output */ /* ------------------------------------- */

getchar(); return 0;

}

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!