This repository was archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathIfElse.java
More file actions
50 lines (41 loc) · 1.31 KB
/
IfElse.java
File metadata and controls
50 lines (41 loc) · 1.31 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
41
42
43
44
45
46
47
48
49
50
/*
Given an integer NN as input, check the following:
If NN is odd, print "Weird".
If NN is even and, in between the range of 2 and 5(inclusive), print "Not Weird".
If NN is even and, in between the range of 6 and 20(inclusive), print "Weird".
If NN is even and N>20N>20, print "Not Weird".
We given you partially completed code in the editor, complete it to solve the problem.
Input Format
There is a single line of input: integer NN.
Constraints
1≤N≤1001≤N≤100
Output Format
Print "Weird" if the number is weird. Otherwise, print "Not Weird". Do not print the quotation marks.
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class IfElse {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
String ans="";
if(n%2==1){
ans = "Weird";
}
else{
if (n>=2 && n<=5) {
ans = "Not Weird";
}
if (n>=6 && n<=20) {
ans = "Weird";
}
if (n>20) {
ans = "Not Weird";
}
}
System.out.println(ans);
}
}