public class CheckOddEven {
/**
* This method will check your number i.e the number is even or not
* @return
*/
public boolean isEven(int number) {
return (number % 2 == 0);
}
}
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
int number;
number = 40; // input to check i.e input is odd or even
System.out.format("The number is : %d\n",number);
CheckOddEven checkOddEven = new CheckOddEven();
if(checkOddEven.isEven(number))
System.out.println("The number is Even");
else
System.out.println("The number is odd");
}
}
/**
* This method will check your number i.e the number is even or not
* @return
*/
public boolean isEven(int number) {
return (number % 2 == 0);
}
}
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
int number;
number = 40; // input to check i.e input is odd or even
System.out.format("The number is : %d\n",number);
CheckOddEven checkOddEven = new CheckOddEven();
if(checkOddEven.isEven(number))
System.out.println("The number is Even");
else
System.out.println("The number is odd");
}
}
No comments:
Post a Comment