-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOddities.java
39 lines (32 loc) · 935 Bytes
/
Oddities.java
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
/* Author:
Kevin Foong 20/09/2019 1.57am
Method:
collect variable input test cases n
use n to limit the number of cases
if else decision making statement to decide, with condition.
print
*/
import java.util.Scanner;
import static java.lang.System.out;
import static java.lang.System.in;
public class Oddities {
public static void main(String[] args) {
Scanner sc = new Scanner(in);
int n, x; //no of test cases, input integer
do {
n = sc.nextInt();
} while (n < 1 || n > 20);
for (int count = 1; count <= n; ) {
x = sc.nextInt();
if (x <= 10 && x >= -10) {
count++;
if (x % 2 == 0) {
out.println(x + " is even");
} else {
out.println(x + " is odd");
}
}
}
sc.close();
}
}