Computer Science Canada Help with string array, |
Author: | netninja [ Thu Feb 12, 2004 11:35 am ] |
Post subject: | Help with string array, |
% The "Average Speed" Program setscreen ("graphics") var AS: array 1..7 of string:= init ("starthour", "endhour", "startmin", "endmin", "totalhours", "distance", "totalmins") var font: int font := Font.New ("serif:28") Draw.Text ("Welcome to the Average Speed program", 6, 10, font, red) Font.Free (font) put "Please enter your Staring hour" get AS (1) put "Please enter Ending hour" get AS (2) put "Enter the starting minute" get AS (3) put "Enter the Ending minute" get AS (4) put "Please enter Distance travelled in KM" get AS (6) AS (5):= AS (2) - AS (1) AS (7):= AS (4) - AS (3) put "Your total time was ", AS (5) put "Your average speed was " Theres an end error, also, it says operands of '-', must be integer, real, or compatible sets. So i tried with int, instead of string, but that would be confusing to somebody reading the code. I guess i could put a % note. But i donnno if my teacher would allow that. Anyone have an idea? Also, obviously the code isnt done, the end isnt complete, but im not concerned, i can fix it quick. |
Author: | Andy [ Thu Feb 12, 2004 11:44 am ] |
Post subject: | |
u cant subtract a string from another... u can add tho |
Author: | TheXploder [ Thu Feb 12, 2004 1:01 pm ] | ||
Post subject: | |||
Why do you use string when you don't even need it when calculating integers? Try this:
|
Author: | Cervantes [ Thu Feb 12, 2004 3:50 pm ] |
Post subject: | |
you can use strintok and strint but making the array of int would be much better. |