Computer Science Canada Calculate time |
Author: | sockoo [ Fri Jun 03, 2005 12:00 pm ] |
Post subject: | Calculate time |
hey all .. i yet again need ur help .. i have to create a program in which tells me how much time has gone by sence midnight .. hense if the user has entered 14:25 it would output 865 minutes .. i know how to program it but .. how would i figure out the minutes from midnight till 14:25 ? .. there's 60 minutes in an hour but .. would i times 14.25 * 60 = 855 .. so0o im 10 off .. where am i going wrong unless my teacher wrote the question wrong |
Author: | lyam_kaskade [ Fri Jun 03, 2005 12:06 pm ] |
Post subject: | |
The problem is 14.25 isn't the same as 14:25 since there are 60 minutes in an hour 0.25 = 1/4 = 15 /60 so 14.25 would be 14:15, not 14:25 what you need to do is take the hours (14) times 60 and then add the minutes (25) so, hours*60 +minutes |
Author: | lyam_kaskade [ Fri Jun 03, 2005 12:25 pm ] | ||
Post subject: | |||
|
Author: | sockoo [ Fri Jun 03, 2005 12:26 pm ] | ||
Post subject: | |||
alright thanks but i'v still got a problem ...
|
Author: | lyam_kaskade [ Fri Jun 03, 2005 12:46 pm ] |
Post subject: | |
Hmmm...I'm not sure I follow. The strreal won't work unless the string is made of entirely integers/decimals. In this case it would have a colon ("14:25)" which can't be changed. Why do you need to strreal it anyway? Do you need the time in hours or minutes? |
Author: | sockoo [ Fri Jun 03, 2005 2:53 pm ] | ||
Post subject: | |||
it had to be in minutes .. but i just took the ez way out ..
it for was for a test .. and i didnt have enough time so0 hey it works .. he never said how it had to be done ![]() |