Getting correct output but,produces warnings during code analysis for each of the variables declared as double. Tried best to give result for 1 hour period. Kindly check give solution to pass test.
package com.codegym.task.task04.task0416;
/*
Crossing the road blindly
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String srno = reader.readLine();
double rno = Double.parseDouble(srno);
double[] green_flag_start = new double[13];
double[] green_flag_stop = new double[13];
double green_inc = 0.00;
int i;
for (i=0; i<=11; i++)
{
green_flag_start[i] = green_inc;
green_flag_stop[i] = green_flag_start[i] + 2.59;
green_inc = green_inc + 5.00;
}
double[] yellow_flag_start = new double[13];
double[] yellow_flag_stop = new double[13];
double yellow_inc = 3.00;
int x;
for (x=0; x<=11; x++)
{
yellow_flag_start[x] = yellow_inc;
yellow_flag_stop[x] = yellow_flag_start[x] + 0.59;
yellow_inc = yellow_inc + 5.00;
}
double[] red_flag_start = new double[13];
double[] red_flag_stop = new double[13];
double red_inc = 4.00;
int y;
for (y=0; y<=11; y++)
{
red_flag_start[y] = red_inc;
red_flag_stop[y] = red_flag_start[x] + 0.59;
red_inc = red_inc + 5.00;
}
double z;
int a;
for (z=0,a=0; z<=55.00 && a<=11; a++,z=z+5.0)
{
if ((rno >= green_flag_start[a]) && (rno <= green_flag_stop[a]))
{
System.out.println("green");
}
else if ((rno >= yellow_flag_start[a]) && (rno <= yellow_flag_stop[a]))
{
System.out.println("yellow");
}
else if ((rno >= red_flag_start[a]) && (rno <= red_flag_stop[a]))
{
System.out.println("red");
}
}
}
}