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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started