-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfElse.java
More file actions
40 lines (37 loc) · 1.25 KB
/
IfElse.java
File metadata and controls
40 lines (37 loc) · 1.25 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
//Task
// Given an integer, n, perform the following conditional actions:
// • Ifn is odd, print Wei rd
// • If n is even and in the inclusive range of 2 to 5, print Not Wei rd
// • Ifn is even and in the inclusive range of 6 to 20, print Wei rd
// • Ifn is even and greater than 20, print Not Wei rd
// Complete the stub code provided in your editor to print whether or not n is
// weird.
// Input Format
// A single line containing a positive integer, n.
// Constraints
// • 1 < 100
// Output Format
// Print Wei rd if the number is weird; otherwise, print Not Wei rd.
// Sample Input O
// 3
// Sample Output O
// Wei rd
import java.util.Scanner;
public class IfElse {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n%2==1){
System.out.println("Weird");
}
else if (n%2==0&&(n<=5&&n>=2)){
System.out.println("Not Weird");
}
else if (n%2==0&&(n<=6&&n>=20)){
System.out.println("Weird");
}
else if (n%2==0&&(n>=20)){
System.out.println("Not Weird");
}
}
}