Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

#include

#include

#include

using namespace std;

void produce_random_numbers(unsigned int lower, unsigned int upper)

{

// 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:

image text in transcribed

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

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

Question

a. Did you express your anger verbally? Physically?

Answered: 1 week ago

Question

b. Did you suppress any of your anger? Explain.

Answered: 1 week ago