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

Username:   Password: 
 RegisterRegister   
 have varibles in place of line draw points
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
LittleRy




PostPosted: Thu Sep 24, 2009 6:54 pm   Post subject: have varibles in place of line draw points

this is the code i got. and my problem is half way down, but other wise it works, if i take out the, draw.line, line
sorry to bug you guys a again.
____________________________________
var slope : real
var x : real
var b : real

var x1 :real
var y1 : real

var x2 : real
var y2 : real

var x3 : real
var y3 : real

put "make a line"
put "enter x and y cordnates for two points"
loop
var reply1 : string (1)
var reply2 : string (1)
put "what is X1?"
get x1
put "what is Y1?"
get y1
put "what is X2?"
get x2
put "what is Y2?"
get y2
slope:=y2-y1/x2-x1
b:=(slope*x1)-y1
put "the equation is y=",slope,"x+",b
Draw.Line(x1,y1,x1,x2,2) <--------------it will not let me put in the varibles for the points needed for the line, what am i doing wrong?
loop
put "test if point is on the line"
put "what is the X value?"
get x3
put "what is the Y value?"
get y3
%test
if y3=slope*x3+b then
put "yes the point ",x3,",",y3," is on the line y=",slope,"x+",b
else
put "no the point ",x3,",",y3," is not on the line y=",slope,"x+",b
end if
end loop
end loop
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Sep 24, 2009 7:48 pm   Post subject: RE:have varibles in place of line draw points

check out Draw.Line. You're using the wrong variable type.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Kharybdis




PostPosted: Thu Sep 24, 2009 8:09 pm   Post subject: RE:have varibles in place of line draw points

Your problem is that you're trying to specify a coordinate that's a real number...

That just won't work in turing. It has to be whole numbers.

Thus, your variables should all be declared integers (or strings if you want to error trap), instead of reals.
LittleRy




PostPosted: Thu Sep 24, 2009 8:21 pm   Post subject: RE:have varibles in place of line draw points

ok thanks guys
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  [ 4 Posts ]
Jump to:   


Style:  
Search: