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

Username:   Password: 
 RegisterRegister   
 Help! With Get Statements!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
good_fella




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




PostPosted: Thu Oct 02, 2003 11:49 pm   Post subject: (No 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
hackman




PostPosted: Fri Oct 03, 2003 10:54 am   Post subject: (No 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).
Display posts from previous:   
   Index -> Programming, Turing -> Turing 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: