Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me in solving this using C++ with function array. Also, 3 functions are compulsory to use which is given in project restriction. In

Please help me in solving this using C++ with function array. Also, 3 functions are compulsory to use which is given in project restriction.

image text in transcribed

In part 01 you're going to write the core of the application: input, interaction with the user, output. Bank 2.0 now supports N> 0 customers, each with an account number (positive integer) and a balance (a real number that can be negative, zero, or positive). In part 01 you're going to support the same set of interactive commands as project 01: +, -,?,^, *, and x. The only difference is that the * command will output a subset of accounts --- those within a specific range of account numbers. Here's a summary of the commands: Page 1 of 9 1. Deposit: + account balance 2. Withdrawal: - account balance 3. Check balance: ? account 4. Find the account with the largest balance: ^ 5. List accounts that fall within low..high: * low high [Note that low and high do not need to be existing accounts. ] 6. Exit: x ** Welcome to Bank v2.0 ** Enter bank filename> bankv2-1.txt ** Inputting account data... ** Checking arrays... 1. 7, $250.98 5. 9921, $1250.75 ** Processing user commands... Enter command (+, -, ?, ^, *, x): * 7 9921 Account 7: balance $250.98 Account 34: balance $-19.00 Account 123: balance $5ee0000.25 Account 467: balance $24.08 Account 9921: balance $1250.75 Enter command (+, -, ?, ^, *, x): Another difference is the banking file format: the first line of the file contains N, the # of bank accounts. For example, here are the contents of the "bankv2-1.txt" banking file that we'll be using for demonstration purposes: 5 7 250.98 34 -10.00 123 5000000.25 467 24.08 9921 1250.75 Note three differences from the previous project: (1) the first line of the file contains the # of bank accounts (5 in this case, but this will change), (2) the data is now guaranteed to be in ascending order by account number, and (3) the balances are always in a fixed format with 2 digits of precision. You may assume the file format is valid, no error checking of the file contents is required. Account 123: balance $5000000.25 Enter command (+,-, ?, ^, *, *): oops ** Invalid command, try again... Enter command (+,-, ?, ^, *, x): 9921 500 Account 9921: balance $1750.75 Enter command (+, -, ?, ^, *, *): 34 10 Account 34: balance $-20.00 Enter command (+, -, ?, ^, *, x): ? 123 Account 123: balance $5000000.25 Enter command (+, -, ?, ^, *, *): ? 99 ** Invalid account, transaction ignored Enter command (+, -, ?, ^, *, x): The screenshot to the right shows a sample run based on *** Saving account data... ** Done ** the "bankv2-1.txt" text file. When the user enters "x" to exit the loop, the program writes the account data back to the same file and ends. Here's the corresponding "bankv2- 1.txt" file after execution of the above: The screenshot to the right shows a sample run based on ** Saving account data... ** Done ** the "bankv2-1.txt" text file. When the user enters "X" to exit the loop, the program writes the account data back to the same file and ends. Here's the corresponding "bankv2- 1.txt" file after execution of the above: 5 7 250.98 34 -20.00 123 5000000.25 467 24.08 9921 1750.75 Notice the first line is N, and the remaining lines use a fixed format with 2 digits of precision. You'll need to configure the output file much like we do the console output: out file at the top of "main.cpp". Your program is required to check if the filename entered can be successfully opened for input. If not, your program should output an error message and immediately return 0; you can assume that if it was opened successfully for input, it will successfully open for output (though it never hurts to check). Example: ** Welcome to Bank v2.0 ** Enter bank filename> pizzabank.txt W Inputting account data... **Error: unable to open input file 'pizzabank.txt' Proiect restrictions program should output an error message and immediately return 0; you can assume that if it was opened successfully for input, it will successfully open for output (though it never hurts to check). Example: ** Welcome to Bank v2.0 ** Enter bank filename> pizzabank.txt ** Inputting account data... **Error: unable to open input file 'pizzabank.txt' Project restrictions How you solve the problem is just as important as developing a correct solution. In this assignment we are going to impose the following restrictions, which you must adhere to. Breaking a restriction typically leads to a score of o. 1. No global variables. A global variable is a variable declared in "main.cpp" but outside of any functions. Use local variables and parameters instead of global variables. 2. The only data structure permitted is dynamically-allocated arrays, created using the new operator. No other data structures: no static arrays, no vectors, no linked-lists, no use of the built-in C++ containers. To be more specific, you'll need to have 2 dynamically-allocated arrays: one for the accounts (an int array), and one for the balances (a double array). The expectation is that the size of these arrays will dynamically adapt based on the input file, and any accounts that may be added or deleted (part 02). It is not acceptable to allocate larger arrays than required and assume those will be big enough; such an approach will yield a project score of O. 3. To help enforce restriction #2, your main() function is required to call the following function: void checkArrays(int accounts[], double balances[], int N); This will be discussed in more detail in the next section ("Getting Started"). 4. To help enforce good design, you are required to provide (and use) the following two functions: int search(int accounts[], int n, int acct); int maxBalance (double balances[], int N); This will be discussed in more detail in the next section ("Getting Started"). 5. This assignment is about arrays, not files. You are allowed to open the banking file exactly twice, once for input at program start and again for output at program end. 6. No use of the built-in algorithms for searching, sorting, min, max, etc. When necessary, you'll write your own functions. 7. Your program must represent a general solution, e.g. the ability to input & process any banking file not

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

Question Can a self-employed person adopt a profit sharing plan?

Answered: 1 week ago