import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc1 = new Scanner(System.in);
double t = sc1.nextInt();
if (t >= 0 && t < 3)
{
System.out.println("green");
}
else if (t >= 3 && t < 4)
{
System.out.println("yellow");
}
else
{
System.out.println("red");
}
}
}
Can someone help??
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
krystian
25 November 2019, 19:02
Any ideas how can I add something so the cycle repeats ?
0
Guadalupe Gagnon
25 November 2019, 19:04
loop is what you asking for, modulo operator is what you mean.
0
Guadalupe Gagnon
25 November 2019, 16:59
the code is too narrow. Any input above 4 will be red. This is incorrect as the code should correctly take an amount of minutes past 0 and figure out what the light should be. So:
If the input is 5 the output should be "green"
if the input is 8 the output should be "yellow"
if the input is 102 the output should be "green"
0
krystian
25 November 2019, 16:20
Still there is something wrong with my code :/
0
Chuanhai Xu
24 November 2019, 23:01
should be
for coherent types
also, you should attach the task the next time you ask a question to make it easier for people to answer it, i believe there is a checkmark for it when you ask a question
0