Skip to content

Instantly share code, notes, and snippets.

@w3farid
Created March 4, 2016 04:20
Show Gist options
  • Save w3farid/3223bbc260e643676a2f to your computer and use it in GitHub Desktop.
Save w3farid/3223bbc260e643676a2f to your computer and use it in GitHub Desktop.
How to calculate Odd Even Number by java
import java.util.Scanner;
public class OddEven {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Calculate the Odd or Even: ");
//check odd even number...........
int a=sc.nextInt();
do{
//check formula 10%2==0 ;
if (a%2==0) {
System.out.println("The number is Even.");
}else {
System.out.println("The number is Odd.");
}
a=sc.nextInt();
}while(a>0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment