Computer Science Canada

Help! With Get Statements!

Author:  good_fella [ Thu Oct 02, 2003 11:06 pm ]
Post subject:  Help! With Get Statements!

i need to write a program that gets like a time of day.

so the user has to input something like "8:30 am"


the program asks for two times. a time you started a trip at and a time you finished the trip at. it then needs to ask for the distance travelled in kilometeres and output the average speed.

so really what i need to know is if i can get two things (in the example 8:30 am) the hours (8) and the minutes (30) on one line seperated by a (:). is this possible? does anyone understand wut im asking?

Author:  Tony [ Thu Oct 02, 2003 11:49 pm ]
Post subject: 

yeah... something like
code:

var t:string

get t:* %takes whole line with spaces

put t(1..index(t,":")-1)
put t(index(t,":")+1..index(t,":")+2)


index(string,substring) returns the place where substring is found inside the string. It is used to locate : in the input. Minutes are hardcoded to be 2 digits.

If am/pm matters, read last two letters to determine, then convert to 24hour system.

you can use
code:

strint(string)


to turn a string into an integer value.

Author:  hackman [ Fri Oct 03, 2003 10:54 am ]
Post subject: 

I had to do the same program about 2 weeks ago. To bad i dont still have it saved. Well i cant realy help much now(im in class, not even suposed to be on the net) but i can try and help you when i get home(if i have enough time).


: