Sample Exam 2

Problem 2b

For this problem, the project can be found in the folder SE2-2b.

The main program arbitrarily chooses bounds. You need to write a method that

a) uses these bounds as input and
b) returns a random int that is within these bounds.
You need to
a) write a method that verifies that produces a int within the bounds
b) write method calls (within the main program) that invoke this method to produce the correct result.

Sample Output:
 

Sample Exam2 - Problem 2b

What is the lower (inclusive) bound of the range? 5
What is the upper (inclusive) bound? 10
A random value from the range is 10
A random value from the range is 6
A random value from the range is 6
A random value from the range is 8
A random value from the range is 9
A random value from the range is 8
A random value from the range is 5
A random value from the range is 10
A random value from the range is 8
A random value from the range is 7


Hint: you should run your program with a small range to make certain that the method actually can produce the inclusive upper and lower bounds. You may have to run the program a few times to encounter this.