Computer Science Canada

Basic Turing Help for a beginner.

Author:  jacobshort1998@hotmail.co [ Thu Mar 05, 2015 12:05 am ]
Post subject:  Basic Turing Help for a beginner.

What is it you are trying to achieve?
A program that asks the user if they want to draw a triangle, circle, or triangle. And then allows them to choose coordinates.

What is the problem you are having?
How to get the coordinates properly, I don't think I have it right. And "THEN" after "ELSE" says its a syntax error...


Describe what you have tried to solve this problem
I've played with the code and solved a bunch of other problems and this one is stumping me, I'm very new to Turing, so yes it's probably going to seem pretty beginner level...


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
This is my code I have done, it's overdue and I don;t want to fall behind, any help would be greatly appreciated, thanks!

Turing:



var x,y : int
var choice: string
var triangle: string
var rectangle: string
var circle: string
var draw: string
var t,c,r : string


put "Do you want to draw a triangle, rectangle or circle? (t, c, or r)"
    get choice
put "Where would you like to place it? (x,y)"
    get x,y
   
loop

if choice = ("t") then
    draw:=triangle (x)(y)
   
elsif choice = ("c") then
    draw:=circle (x)(y)
   
else choice := ("r") then
    draw:=rectangle (x)(y)
   
end if

end loop



Please specify what version of Turing you are using
4.1.1

Author:  Zren [ Thu Mar 05, 2015 12:40 am ]
Post subject:  RE:Basic Turing Help for a beginner.

You're treating else as an elsif. Just use the elsif keyword instead.

Read the documentation on how to write an if statement.


: