Computer Science Canada have varibles in place of line draw points |
Author: | LittleRy [ 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 |
Author: | Tony [ 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. |
Author: | Kharybdis [ 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. |
Author: | LittleRy [ Thu Sep 24, 2009 8:21 pm ] |
Post subject: | RE:have varibles in place of line draw points |
ok thanks guys |