I have tried this code into IntelliJ Idea with several inputs and it seems to be working well, but here I am getting Green and Yellow don't work. You could see my thought process in the code below.
Thanks for your help
package com.codegym.task.task04.task0416;
/*
Crossing the road blindly
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader inputString = new BufferedReader(new InputStreamReader(System.in));
String input = inputString.readLine();
double t = Double.parseDouble(input);
/* **** GREEN LIGHT ****
[0,2.9],[5,7.9]...[55,57.9]
**** YELLOW ****
[3,3.9],[8,8.9]...[58,58.9]
**** RED ****
[4,4,9],[9,9.9]...[59,59.9]
From one interval to the other we jump 5 units
Green: the lowest t%5 is 0 (0%5 = 0), and the highest is 57.9%5 = 2.9
Yellow: the lowest modulo is 3%5 = 3, and the highest is 58.9%5 = 3.9
No need to do red because it comprises the rest of possibilities.
*/
if (t%5 >=0 && t%5<=2.9){
System.out.println("green");
}
else if (t%5>=3 && t%5<=3.9){
System.out.println("yellow");
}
else
System.out.println("red");
}
}