Posted: Thu Apr 28, 2005 8:15 am Post subject: Time Conversion
I wrote a program that gets the length and width of a housing lot from the user and get the area. It then takes the area and figures out how many minutes it will take to mow the lawn at 2 square meters per minute. The problem is the program out puts how long it will be in minutes and I need it to display the time in hours after it gets past 60 minutes. Does anybody here know?
Sponsor Sponsor
Martin
Posted: Thu Apr 28, 2005 8:34 am Post subject: (No subject)
How many minutes are in an hour?
If I say that I've been doing something for 180 minutes, you simply divide that by 60 and you know that I've been working for 3 hours.
Now, given an odd amount, like say 213 minutes, here's what you do:
code:
int hours, minutes;
int time = 213;
hours = time / 60;
minutes = time - 60 * hours;
wtd
Posted: Thu Apr 28, 2005 11:37 am Post subject: (No subject)
Martin wrote:
code:
int hours, minutes;
int time = 213;
hours = time / 60;
minutes = time - 60 * hours;
More succinctly:
code:
int time = 213;
int hours = time / 60;
int minutes = time % 60;