Can anyone help me please? i need to create a program in which you enter a distance and the program will tell you how long it will take to get there in hours minutes and seconds.
My trouble is that they all display independently and not seperately ... for example ... i want it to display "1 hour 20mins 4 seconds" instead of "1.20 hours 80 mins" and how ever many in seconds.
thank you in advance for your help :)
public class Travel{
public static void main (String [] argv){
//variables
final float kph =85;
float distance;
float sec;
float min;
float hour;
float subtot;
// float total;
// float grandtot;
// prints out user prompt
System.out.println("Please Enter the Distance: ");
distance = UserInput.readFloat ();
// formula to work out length of travel
subtot = distance/kph;
// hour = subtot%10;
// total = distance/kph*60;
// min = total%10;
// grandtot = distance/kph*60*60;
// sec = grandtot%10;
min = subtot*60;
hour = min % 60;
sec = min*60;
//total= subtotal*60;
// total = distance/kph;
//timeInMin =
System.out.println("Time in Hours: "+hour);
System.out.println("Time in Minutes: "+min);
System.out.println("Time in seconds: "+sec);
System.out.println("The Total Time is: "+hour+":"+sec+":"+min);
}
}