Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Time Conversion
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Scooter341




PostPosted: 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
Sponsor
sponsor
Martin




PostPosted: 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




PostPosted: 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;
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: