Question
You're going to write the main() program to input bank account data, and then output the following information to the console: all account numbers and
You're going to write the main() program to input bank account data, and then output the following information to the console:
- all account numbers and balances, one per line (format: "Account ?: balance $?.??")
- the min balance (format: "Min balance: $?.??")
- the max balance (format: "Max balance: $?.??")
- the total deposits in the bank, i.e. the sum of positive balances (format: "Total deposits: $?.??)
The bank account data is stored in an array of struct, which is input by a function named inputData. The structure and input function have been written for you, defined as follows:
struct BankAccount { int Account; double Balance; }; // // inputData // // Given a value N, generates an array of N random bank accounts and // balances. A pointer to this dynamically-allocated array is returned; // BankAccount* inputData(int N)
These are defined in "util.h" and "util.cpp" respectively. Your assignment is to write the main program by calling the inputData function. You pass N to the function, and the function returns a dynamically-allocated array of N randomly-generated account numbers and balances. Then analyze the array and output the required information. You should delete the array before returning.
/*util.cpp*/
#include
using namespace std;
// // inputData // // Given a value N, generates an array of N random bank accounts and // balances. A pointer to this dynamically-allocated array is returned. // The main() program should delete this array before returning. // BankAccount* inputData(int N) { BankAccount* data = new BankAccount[N]; srand(456 + N); for (int i = 0; i < N; i++) { data[i].Account = 1 + (rand() % 10000); if (rand() % 10 < 5) // negative: data[i].Balance = -(rand() % 1000); else data[i].Balance = (rand() % 1000); data[i].Balance += (static_cast
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started