Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

1. Sales results over time.

Answered: 1 week ago