For staters, you don't need to be using floats for hour, sec, min and this is where a lot of your issues will be starting.
If you avoid decimal multiplication / division, you will probably get results closer to what you want. e.g. 1.20 = 1 in int (I am referring to your hours).
After you calculate hours, you need to take this into account when calculating the minutes. After you get the minutes you need to take this & hours into account when you calculate the seconds.
Hope this helps...
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
In Physics everything is measured in meters and seconds.
So after you get the speed and distance, Convert both to meters/sec and meters. After you do the division you will have a clean value in seconds which can be easily converted to minutes and hours.
If the final value has decimal points: 65.33 seconds then keep them at the seconds value or round them or have another variable for miliseconds:
1 minute and 5.33 seconds or
1 minute and 5 seconds or
1 minute and 5 seconds and 330 milliseconds
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
... 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. ...
min = subtot*60;
hour = min % 60;
sec = min*60;
min = subtot * 60;
if ( min >= 60){
hour = min%60;
}
else{
hour = 0;
}
if (hour != null){
min -= (hour*60);
}
that should fix that. once you've taken them as hours, subtract the right amount of minutes from min to get the correct answer
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
Nice work, you can mark the thread as solved so that people know too.
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64