Question: Complete the following method, called numberInfo, that takes an integer parameter called input, and returns a String depending on the value of input. If input
Complete the following method, called numberInfo, that takes an integer parameter called input, and returns a String depending on the value of input.
If input is positive, numberInfo will return the String "positive".
If input is zero, numberInfo will return the String "zero".
If input is negative and odd, numberInfo will return the String "odd".
If input is negative and even and divisible by five, numberInfo will return the String "magic"
If input is negative and even but not divisible by five, numberInfo will return the String "even"
Examples:
System.out.print(numberInfo(2));
prints "positive"
System.out.print(numberInfo(3));
prints "positive"
System.out.print(numberInfo(0));
prints "zero"
System.out.print(numberInfo(-9));
prints "odd"
System.out.print(numberInfo(-10));
prints "multi"
System.out.print(numberInfo(-14));
prints "even"
public static String numberInfo(int input) {
//write the method body code in the box below
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
