Question: Create a class called Methods with 8 methods (including the main method). The class Methods must be public. All methods must be public and static.
Create a class called "Methods" with 8 methods (including the main method). The class "Methods" must be public. All methods must be public and static.
Method name: average
Input: 3 floats
Output: 1 float
Purpose: returns the average of 3 numbers
Method name: max
Input: 4 floats
Output: 1 float
Purpose: returns the largest of 4 numbers
Method name: evenlyDivides
Input: 2 ints
Output: 1 boolean
Purpose: returns true if second parameter evenly divides the first; returns false otherwise
Method name: isEven
Input: 1 int
Output: 1 boolean
Purpose: returns true if parameter is even; returns false otherwise
Method name: isPrime
Input: 1 int
Output: 1 boolean
Purpose: returns true if parameter is a prime number; returns false otherwise
Method name: sumPriors
Input: 1 int
Output: 1 int
Purpose: returns the sum of all numbers between 1 and the parameter (include the parameter in the sum)
Method name: message
Input: nothing
Output: String
Purpose: returns "Done!"
Method name: main
Input: String[] args
Output: void
Purpose: test your code by printing the return of the following method calls in order. Each call should be printed on a newline. Your "print" method will be very useful here. Note: the following is NOT valid java code. It just gives you an idea of what to print.
average(1,2,3)
max(1,2,3,4)
evenlyDivides(18,2)
isEven(5)
isPrime(14)
sumPriors(6)
message()
Output (newline characters are shown as ):
2.0 4.0 true false false 21 Done!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
