Question: Bank Customers Data You are asked to develop an application that prints a bank customers names, IDs, and accounts balances in different ways after calculating
Bank Customers Data
You are asked to develop an application that prints a bank customers names, IDs, and accounts balances in different ways after calculating how much money they have in their different accounts. In this program you need to read a file of customers data into different arrays, pass these arrays to functions as (array parameter), calculate the total balance for each customer, then print some information. The input file input.txt contains the following information (ID, first name, last name, savings account balance, checking account balance). You have to store these different columns in different arrays where each index represents a customer data. Preliminaries We will consider the file contains 10 rows maximum. So all your arrays size must be at least 10. Since the size of all the arrays is 10, so it is better to create a constant variable with the value 10 than hard coding the arrays size. Hint: You will need to pass this constant to your functions later on as your array size to limit your loops iterations. Create five different arrays with different types based on the data in the file. Create an ifstream object to read the data from the input file. Read and store the data from the input file in your arrays using a single for loop. Create a switch statement with four options and the output should be generated based on the chose option. Check the options bellow:
Required functions: 1. A function printCustomersData should be called when the user chooses the first option. This function is of type void (it does not return anything). printCustomersData function accepts six parameters (five arrays and the size). This function should print a table of the customers data. Check the function prototype below: void printCustomersData(const int id[], const string first[], const string last[], const double savings_Account[], const double checking_Account[], int size); Output of option 2: Note that the switch statement must be inside a while loop, which means that after each option selection, the options will be printed again. 2. The function printNames prints the ID, first, and last name of each customer (the output should also be as a table). This function accepts four parameters (three arrays and the size). See the function prototype bellow: void printNames(const int id[], const string first[], const string last[], int size); 3. The function printTotal that prints all customers IDs, the balance of the savings account, the balance of the checking account, and the total balance for each customer (savings balance + checking balance). As mentioned before, the output has to be in a table. This function accepts four parameters (three arrays and the size). This is the function prototype: void printTotal(const int id[], const double savings_Account[], const double checking_Account[], int size); If the user entered something not in the options such as the letter a, the application should not be terminated. Instead, the application should print a message that tells the user that his/her input was incorrect, then the options should be displayed again, and the application should ask the user to enter another option. As mentioned before, the options will be printed after each selection. Even when the user enters an invalid value. The only way to terminate the program is to enter q or Q which is the fourth option.
Control Flow: The application should start by reading the data from the input file. Then create a while loop to repeat the options after each selection. Within the while loop, create your switch statement that contains the different options. Each case/option inside the switch statement should execute a function call.
Hints: All arrays must be passed as constant array parameters, since all functions will print these arrays without changing their items value. Create a constant variable to use it as the size of the arrays. Create an if statement to check if the file reading process went well. You can use many expressions such as: (!fin) or (fin.fail()), etc. Do not forget the break statement after each case inside the switch statement. Use the function setw(number) that helps you to print the data in a shape of table. This function sets the number of spaces for each output. The function is in the library. Do not forget to write a proper algorithm at the beginning of your code. Write some comments that help the reader to understand the purpose of each loop and function. Inside functions, write preconditions and postconditions.
data from input file
10 Homer Smith 810.2 101.10 20 Jack Stanely 100.0 1394.90 30 Daniel Hackson 333.90 7483.77 40 Sara Thomson 1930.02 4473.20 50 Thomas Elu 932.0 2334.30 60 Sam Carol 33.0 0.0 70 Tina Jefferson 334.90 777.5 80 Wael Lion 8843.2 88.90 90 Carol Smith 3994.09 2343.30 100 Jack Carlton 99.0 8433.04
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
