Computer Science Canada

Some quick help...

Author:  HKYPLAYA4LIFE [ Wed Dec 24, 2003 12:11 am ]
Post subject:  Some quick help...

I started writing this program really quick and then I began getting errors. Please help me out quick thanks. Very Happy
(sorry about the messy from by the way)
code:
colourback(green)
cls
colour(red)
put "Hello"
delay (1000)
put "Could I please get you to enter your name: "..
var name:string
get name
delay(500)
put "Thank you ",name,"."
delay(500)
put "Rather than buying a material gift this year ",name,","
put "I decided to write you this computer program."
delay(5000)
cls
colourback(white)
colour(black)
cls
delay(2000)
put name," what would you like me to do?"
put""
put""
put "1. Open Calculator"
put "2. Open Averager"
put "3. Open one of your computer drives"
put "4. Play a game"
put ""
put ""
put "Press the number of choice then press the enter key."
put""
put""
var thing:int
get thing
if thing=1 then
cls
put "First I will need you to input two numbers that you would like to use in your mathematical equation"
var one,two : real
put "Input your first number: "..
get one
delay(500)
put "Input your second number: "..
get two
delay(500)
put"Now ",name,", what would you like to do with this two numbers:"
put""
put""
put"1. Add"
put"2. Subtract"
put"3. Multiply"
put"4. Divide"
var func :int
get func
put "Thank you ",name,"."
delay(1000)
cls
if func=1 then
put one,"+",two,"=",one + two
end if
else if func=2 then
put one,"-",two,"=",one - two
end if
if func=3 then
put one,"x",two,"=",one**two
end if
if func=4 then
put one,"/",two,"=",one div two
end if

Author:  DanShadow [ Wed Dec 24, 2003 4:00 pm ]
Post subject: 

Lol, such a messed program.
All your problems lie in this part of the code:
code:

else if func=2 then
put one,"-",two,"=",one - two
end if
if func=3 then
put one,"x",two,"=",one**two
end if
if func=4 then
put one,"/",two,"=",one div two
end if

else if is wrong, it is actually elsif
The variables func and one havent even been declared
Fix up these things, and it should fall into place.
Oh, also when dividing, its easier to put / instead of div
Very Happy

Author:  Thuged_Out_G [ Wed Dec 24, 2003 9:29 pm ]
Post subject: 

DanShadow wrote:

The variables func and one havent even been declared


yes they have

Author:  DanShadow [ Thu Dec 25, 2003 10:56 am ]
Post subject: 

Hmmmm...so they are, sorry about that. I guess Turing was drunk when I ran the program....skipped the var statements. Woops, well sorry. (And thanks for the correction Wink )

Author:  Thuged_Out_G [ Thu Dec 25, 2003 3:33 pm ]
Post subject: 

i get the same error, and i dont know why

but try declaring all variables at the beginning of the program, and structure your program a bit better...it makes it much easier to read and follow

HINT:hit f2 in turing after your done the program

Author:  Boarder16 [ Mon Dec 29, 2003 11:59 pm ]
Post subject: 

try using procedures too, i knwo usaid sorry for the form bein messy but its soo messy!!! lol, ahhhahhh i stopped reading it half way because its soo messy, or its just me and i'm a neat freak... Rolling Eyes


: