-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditional.java
More file actions
27 lines (23 loc) · 811 Bytes
/
Conditional.java
File metadata and controls
27 lines (23 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.Scanner;
public class Conditional {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt();
// check number is even or odd
if (num % 2 == 0) {
System.out.println(num + " is an even number.");
} else {
System.out.println(num + " is an odd number.");
}
// check the person(He/She) is eligible to vote or not
System.out.print("Enter your age: ");
int age = sc.nextInt();
if (age >= 18) {
System.out.println("You are eligible to vote.");
} else {
System.out.println("You are not eligible to vote.");
}
sc.close();
}
}