189k views
1 vote
Assume the existence of a class RangeException, with a constructor that accepts minimum, maximum and violating integer values (in that order). Write a function, void verify(int min, int max) that reads in integers from the standard input and compares them against its two parameters. As long as the numbers are between min and max (inclusively), the function continues to read in values. If an input value is encountered that is less than min or greater than max, the function throws a RangeException with the min and max values, and the violating (i.e. out of range) input.

User Mjuice
by
6.5k points

1 Answer

2 votes

Answer:

void verify (int min, int max)

{

int input;

cin >> input;

while (input <max && input >min)

{cin >> input;

if(input > max || input < min)

{throw RangeException (min, max, input);

}}}

User Meena Alfons
by
6.9k points