i'm not able to validate my code as the replay from the system is
that the green condition is not met and i don't understand the reason.
Here below my code:
/*
Crossing the road blindly
*/
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
Scanner read = new Scanner(System.in);
double ora;
ora = read.nextDouble();
if (ora>5){
ora = ora%5;
}
if(ora<3.0){
System.out.println("green");
} else if(3.0<=ora && ora<4.0){
System.out.println("yellow");
} else if(4.0<=ora && ora<5.0){
System.out.println("red");
}
}
}
where is the mistake?
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
max
11 January 2020, 21:50
i changed the code as follows, but once more the output is correct, but the system refuse to
validate it:
import java.util.*;
0
max
6 January 2020, 22:17
hi Horst,
if the input is 5 the answer should be green.
However i tested the code with the option run without verification and it works
correctly, i don't understand why i receive an error msg concerning the green light
option
0
horst
6 January 2020, 21:40
Looks pretty good to me, the only thing I see is the following:
What does your code do if the input is 5?
0