Write an application that asks a user to enter an integer. Display a statement that indicates whether the integer is even or odd.
------------------------------------------
import java.util.Scanner;
class EvenOdd {
public static void main(String[] args) {
// Write your code here
}
public static boolean isEven(int number) {
}
}
In case of any queries,please comment. I would be very happy to assist all your queries.Please give a Thumps up if you like the answer.
Program
import java.util.Scanner;
class EvenOdd {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int num;
System.out.print( "Enter an integer: " );
num = input.nextInt ();
if(isEven(num))
System.out.println(num+ " is Even"
);
else
System.out.println(num+ " is Odd"
);
}
public static boolean isEven(int number) {
if(number%2==0)
return true;
else
return false;
}
}
Output
Enter an integer: 345
345 is Odd
Screenshot
Get Answers For Free
Most questions answered within 1 hours.