Question: Given main ( ) , complete class RandomNumbers ( in files RandomNumbers.h and RandomNumbers.cpp ) that has three integer data members: var 1 , var

Given main(), complete class RandomNumbers (in files RandomNumbers.h and RandomNumbers.cpp) that has three integer data
members: var1, var2, and var3.
Write a getter function for each variable: GetVar1(), GetVar2() and GetVar3().
Then write the following 2 member functions:
void PrintRandomValues()- prints out the 3 random numbers in the format: "Random values: var1 var2 var3"
void SetRandomValues()- accepts a low and high integer values as parameters, and sets var1, var2, and var3 to random numbers
within the range of the low and high input values (inclusive).
To generate a bounded (pseudo)-random value, we use the rand() function. rand() is a built-in cpp function which generates a random value
between 0 and the system constant RAND_MAX. Using a little modular arithmetic, we can bound the results generated by rand() to a [low,
high] interval with the following:
rand()88(high- low +1)+ low
(Note: if you're familiar with seeding srand() for cpp pseudo-random number generation, do not do that for this lab. If you don't know what
this means, ignore it)
Once you're implemented each function that is declared in RandomNumbers.h, in RandomNumbers.cpp, you're finished.
Ex: If the input is:
1520
the output is:
Random values: 171519
where 17,15,19 can be any random numbers within 15 and 20(inclusive).
Note: When submitted, your program will be tested against different input range to verify if the three randomly generated values are within
range.
 Given main(), complete class RandomNumbers (in files RandomNumbers.h and RandomNumbers.cpp) that

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!