Question: Hi! I have a C++ task where I have the following template, where the lower and upper limits are read, from which the random numbers

Hi!

I have a C++ task where I have the following template, where the lower and upper limits are read, from which the random numbers are generated. In addition, it checks that the lower limit is genuinely lower than the upper limit. There is another post like this with a implementation with code "unsigned seed = std::chrono::steady_clock::now().time_since_epoch().count();" but that is too complicated. Could there be a simpler way?

#include

#include

#include

using namespace std;

void produce_random_numbers(unsigned int lower, unsigned intupper)

{

// Implement your function here

}

int main()

{

unsigned int lower_bound, upper_bound;

cout

cin >> lower_bound;

cout

cin >> upper_bound;

if(lower_bound >= upper_bound)

{

cout

return EXIT_FAILURE;

}

produce_random_numbers(lower_bound, upper_bound);

return EXIT_SUCCESS;

}

The task is to implement the function produce_random_numbers, which produces random numbers for the given interval until the user gives the stop command q. There was also a hint: "The commands given by the user (c and q) should be read with the operator >>, because the lower and upper limits are also read with this operator. (In the same program, it is not recommended to read inputs with both the function getline and the operator >>, at least not in order: first >> and then getline."

The program is supposed to work as follows:

Hi! I have a C++ task where I have the following template,

Thank you!

Enter a lower bound: 1 Enter an upper bound: 10 Enter a seed value: 1 Your drawn random number is 1 Press q to quit or any other key to continue: c Your drawn random number is 2 Press q to quit or any other key to continue: c Your drawn random number is 8 Press q to quit or any other key to continue: c Your drawn random number is 5 Press q to quit or any other key to continue: c Your drawn random number is 6 Press q to quit or any other key to continue: c Your drawn random number is 3 Press q to quit or any other key to continue: c Your drawn random number is 1 Press q to quit or any other key to continue

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!