It works as it should be (I've checked it with Eclipse), but at this web-page when I press to check the code the result is negative. What's wrong? The problem in my code or may be in your task?
package com.codegym.task.task04.task0416;
/*
Crossing the road blindly
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
Reader r = new InputStreamReader(System.in);
BufferedReader bR = new BufferedReader(r);
String t = bR.readLine();
double tm = Double.parseDouble(t);
// green 0 - 179 sec
// yellow 180 - 239 sec
// red 240 - 299 sec
while (tm > 60) {
tm = tm - 60;
}
int timeInSec = (int) (tm * 60);
int fullCycle = 299;
int rest = timeInSec % fullCycle;
if (rest < 180) System.out.println("green");
else if (rest >= 180 && rest < 240) System.out.println("yellow");
else System.out.println("red");
}
}