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:

  1. all account numbers and balances, one per line (format: "Account ?: balance $?.??")
  2. the min balance (format: "Min balance: $?.??")
  3. the max balance (format: "Max balance: $?.??")
  4. 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 #include #include "util.h"

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(1 + rand()%100) / 100.0); } return data; }

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!