Skip to content

Commit a50d581

Browse files
committed
even-odd
1 parent c814db2 commit a50d581

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Basic-Java/EvenOdd.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.Scanner;
2+
3+
public class EvenOdd {
4+
5+
public static void main(String[] args) {
6+
7+
int num,flag;
8+
System.out.println("Program to check if the number is even or odd!\n---");
9+
System.out.println("Enter the number: ");
10+
Scanner scanner = new Scanner(System.in);
11+
num = scanner.nextInt();
12+
scanner.close();
13+
14+
flag = num % 2;
15+
if(flag == 0) {
16+
System.out.println("The number you entered is even.");
17+
}
18+
else {
19+
System.out.println("The number you entered is odd.");
20+
21+
}
22+
23+
}
24+
}

0 commit comments

Comments
 (0)