I get the following error when I use the floor function:
com/codegym/task/task04/task0416/Solution.java:17: error: incompatible types: possible lossy conversion from double to int
int a = Math.floor(t);
I've tried making t a double and a float, and adjusting from input.nextDouble to input.nextFloat. Both result in this error. I think my solution can work, but needs tweaking. Any suggestions?
package com.codegym.task.task04.task0416;
/*
Crossing the road blindly
*/
import java.io.*;
import java.util.Scanner;
import java.lang.Math;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner input= new Scanner(System.in);
double t = input.nextDouble();
int a = Math.floor(t);
if (a%5>=0 && a%5<3)
System.out.println("green");
if (a%5>=3 && a%5<4)
System.out.println("yellow");
else
System.out.println("red");
}
}