Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lang C++ : For this assignment, you will create a main.cpp file and a randomnumbers.h header file. A class will be defined in the header

image text in transcribedLang C++ :

For this assignment, you will create a main.cpp file and a randomnumbers.h header file. A class will be defined in the header file (described below). Instances of the class (objects) will be used in main to perform the specified random number generation, calculations, and the results will be printed out (explained below). You will also be using vectors in this assignment. Your program should run as follows: first, the user will be asked to enter a lower bound, an upper bound, and a quantity n. The class will then be used to generate n random numbers in the range [lower...upper]. After this, the average (mean), max, and min will be calculated (in a separate function from the generator), and then another function (print) will print out the lower, upper bounds, n, and the average, max, and min. The user will then be asked if they wish to go again (with possibly new values). 1. Create a header file named randomnumbers.h. Define a class named RandNum. Create private variables (they won't be all of the same type) for n, lower, upper, average, max, min, and vector numbers. Define public functions Randlnput, RandGen, RandCalc, Print. - The Randlnput function should set the values of lower,upper, and n (based on the user input in main). - The RandGen function should first initialize the vector using: numbers.resize(0); then proceed to generate n random numbers in the range [lower...upper] and store each number in the vector (since the vector does not have a predefined size you will have to use push_back i.e. numbers.push_back(randvalue) to store the values). Don't calculate the average, max, and min here (part of this assignment is to make sure you can use vectors). - RandCalc should loop through the vector (use numbers.size() as the loop bound and the denominator in the average calculation) and calculate the average(mean), max, and min values and store them in the private variables. - Print should print out what the user entered as the lower, and upper bounds, the amount of numbers generated, and then the average, max, and min. 2. Create a main.cpp. Make sure you include the necessary header files. Declare an object of class RandNum. Then, within a while loop, ask the user for the lower, upper, and amount, then use the function Randlnput to set the values, and then the 3 other public member functions are executed in order. Make sure you ask the user if they want to go again (this is why you have to initialize the vector to size 0 in RandGen)

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions