The following is my code that works ::
public class AvgSpeed{
public static void main(String[] args){
double kph, km, hours, seconds, minutes, time;
km = (1.6 * 24);
hours = 1;
minutes = 2/3f;
seconds = 35/3600f;
time = hours + minutes + seconds;
kph = km/time;
System.out.println(kph);
}
}
If I remove the f's for minutes and seconds, it keeps printing out 38.4, which is not right. It should be some number close to 22.906
I don't even know the reason why I need to add the f, I did it on a whim. I thought declaring the two variables as a double was enough?