-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaIfElse.java
More file actions
27 lines (23 loc) · 787 Bytes
/
JavaIfElse.java
File metadata and controls
27 lines (23 loc) · 787 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 JavaIfElse {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Integer value = scanner.nextInt();
scanner.close();
String message = "";
if (value % 2 == 1) {
// value is odd
message = "Weird";
} else if (value >= 2 && value <= 5) {
// value is even and in the inclusive range of 2 to 5
message = "Not Weird";
} else if (value >= 6 && value <= 20) {
// value is even and in the inclusive range of 6 to 20
message = "Weird";
} else {
// value is even and greater than 20
message = "Not Weird";
}
System.out.println(message);
}
}