Question: QUESTION: Design a class MinMax that has the following properties: 1- two integer variables min and max that will be kept as max larger than
QUESTION: Design a class MinMax that has the following properties: 1- two integer variables min and max that will be kept as max larger than min as all times. initial value 0 for both 2- setters for each. You have to remember that max need to be >= min at all times, so if you are trying to set max to smaller than min, then min will have the new value and max will be set to the old min. Example: max = 10, min = 5. setMax(2). in this case because the new value is smaller than min, then min wiil be set to 2 and max to the value of min 5 Same for setMin() if you try to set min to larger than max, then max will be set to the new value and min will be et to old max. 3- print() to display min and max. 4- method void add(int n) that will add n to both min and max 5- method void multiply(int n) that will multiply both min and max by n, be careful when multiplying two values by a negative number the order is switched. 4 2 (multiply by -1) result -4 -2 (min and max should be switched in this case) 6- write a min in which you use every method in your class. (Test your class).
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
