a Java program that defines and uses 3 overloaded methods (the Java file name should be “MethodOverload.java” and all the 3 methods should have the same method name max). The 3 method headers are given below with their definitions: • int max(int n1, int n2, int n3): o to return the maximum of the passed 3 integer arguments. • double max(double d1, double d2, double d3): o to return the maximum of the passed 3 double arguments with use of Math.max() method—that is, do not use if or if-else statement in comparing the numbers to find the smaller/smallest numbers. • int max(int n): In the main method of the application, a loop with switch-statement inside is required for testing the different method calls and you need to generate random numbers for the inputs as the arguments for the methods (except for die-rolling case where an input is entered from the keyboard.). Specifically:
a Java program that defines and uses 3 overloaded methods (the Java file name
should be “MethodOverload.java” and all the 3 methods should have the same method
name max). The 3 method headers are given below with their definitions:
• int max(int n1, int n2, int n3):
o to return the maximum of the passed 3 integer arguments.
• double max(double d1, double d2, double d3):
o to return the maximum of the passed 3 double arguments with use of
Math.max() method—that is, do not use if or if-else statement in
comparing the numbers to find the smaller/smallest numbers.
• int max(int n):
In the main method of the application, a loop with switch-statement inside is required for
testing the different method calls and you need to generate random numbers for the inputs
as the arguments for the methods (except for die-rolling case where an input is entered
from the keyboard.). Specifically:
• int max(int n1, int n2, int n3): the 3 random integers should be from the sequence
2, 5, 8, 11, 14.
• double max(double d1, double d2, double d3): the 3 random double numbers
should be from the range [10, 20].
o Hint: a random number from the range [min, max] is generated through
min + (max-min) * randomNumbers.nextDouble();
• int max(int n): the input for the number of rolls n is entered from the keyboard.
Step by step
Solved in 4 steps with 6 images