MCPcopy Create free account
hub / github.com/Hazrat-Ali9/Computer-Programming / Problem18

Class Problem18

Problem18.java:5–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import java.util.Scanner;
4
5public class Problem18 {
6
7 public static String getColor(int number) {
8 if ((number % 2) == 0) {
9 return "blue";
10 } else {
11 return "red";
12 }
13 }
14
15 public static void main(String[] args) {
16 // TODO Auto-generated method stub
17 Scanner input = new Scanner(System.in);
18 int today = 1, n;
19
20 String[] answers;
21 int T = input.nextInt();
22
23 while (T < 1) {
24 T = input.nextInt();
25 }
26
27 answers = new String[T];
28
29 for (int i = 0; i < T; i++) {
30 n = input.nextInt();
31
32 while (n < 0) {
33 n = input.nextInt();
34 }
35
36 answers[i] = getColor(today + n);
37 }
38 input.close();
39
40 for (String answer : answers) {
41 System.out.printf("%s\n", answer);
42 }
43
44 }
45
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected