Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume the existence of a class RangeException, with a constructor that accepts

ID: 3546618 • Letter: A

Question

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.

Explanation / Answer

void verify(int min, int max){

int n;

while(1){

cin >> n;

if(n < min || n > max){

throw RangeException(max, min, n);

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote