
-----------------------------------
sockoo
Fri Jun 03, 2005 12:00 pm

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

-----------------------------------
lyam_kaskade
Fri Jun 03, 2005 12:06 pm


-----------------------------------
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

-----------------------------------
lyam_kaskade
Fri Jun 03, 2005 12:25 pm


-----------------------------------

var time1 : string
var min1 : int := 0
var divid, time2 : int
put "what is the time"
get time1 : *

min1 := strint (time1 (1 .. 2))*60 + strint (60 + time1 (4 .. 5))
[/code]

-----------------------------------
sockoo
Fri Jun 03, 2005 12:26 pm


-----------------------------------
alright thanks but i'v still got a problem ... 


var time1 : string
var min1 : int := 0
var divid, minutes  : int
var time2, time3, time4  : real
put "what is the time"
get time1 : *
time2 := strreal (time1)
time3 := time1 (1 .. 2)
time4 := time1 (4 .. 5)


-----------------------------------
lyam_kaskade
Fri Jun 03, 2005 12:46 pm


-----------------------------------
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?

-----------------------------------
sockoo
Fri Jun 03, 2005 2:53 pm


-----------------------------------
it had to be in minutes .. but i just took the ez way out .. 

var hou, minu : int
put "what is the hour"
get hou
cls
put "what are the minutes"
get minu
cls 
minutes:= hou * 60 + minu
put minutes, " minutes have passed sence midnight" 


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 :P .. heh
