Program that allows practice reading a metric ruler.
I got some more help from the LB forum guys to put together this program. It allows the user to read and input the observed length of a rectangle. It gives the user 5 different rectangles to measure and it gives instant feedback as well as it saves a copy of the results to a file. Caution on the use of the program. Make sure that the file address is suitable for your computer. I worked off of a jump drive so the file was opened, written to, and saved on the g:\ drive. If you are working only on your c:\ drive or some other drive, please change the file address code in the program to reflect the drive to which you are using to save the results. *
Otherwise, it is a straightforward program
[[code]]'This program attempts to give students practice reading a rule.'*** Must set file parameters for your particular situation'*** example "g:\record.txt" vs "c:\record.txt"'*****************************************************'set graphics window parameters'*****************************************************nomainwinopen"g:\record.txt"forappendas#1close#1kill"g:\record.txt"UpperLeftX=500UpperLeftY=150WindowWidth=640WindowHeight=760graphicbox#w.g,10,10,600,500statictext#w.s,"Enter your measurement in the box and click 'Save' button",10,600,600,30textbox#w.tb1,10,550,600,32button#w.b1,"Save",[entered], LR,300,50,60,30open"Measuring Practice"forwindowas#w
#w,"trapclose [quit]"#w.tb1 "!font arial 16 bold"#w.s "!font arial 12"#w.tb1 "!setfocus"'*****************************************'draw the ruler borders'*****************************************#w.g,"goto 50 400"#w.g,"down"#w.g,"goto 50 450"#w.g,"goto 550 450"#w.g,"goto 550 400"#w.g,"goto 50 400"'*******************************************'add the centimeter and .5 centimeter markings'*******************************************[skip1]
x =50
y =400
z =425for j =1to19
x = x +25#w.g,"goto ";x;" ";y
#w.g,"down"#w.g,"goto ";x;" ";z
#w.g,"up"next j
x =50
y =400
z =410#w.g,"up"#w.g,"goto ";x;" ";z
for i =1to100
x = x +5#w.g,"goto ";x;" ";y
#w.g,"down"#w.g,"goto ";x;" ";z
#w.g,"up"next i
'**************************************************'print the numbers 1-9 to label the centimeter marks'**************************************************
x =95
y =430
d =1#w.g,"down"#w.g,"place ";x;" ";y
print#w.g,"\";d
for j =1to8
d = d+1
x = x +50#w.g,"place ";x;" ";y
print#w.g,"\";d
next j
#w.g,"flush"#w.g,"up"'*******************************************************'Draw a rectangle above the ruler and store length as cm'*******************************************************for b =1to5#w.g,"goto 50 400"#w.g,"down"
x =550:y =350print#w.g,"backcolor white"print#w.g,"color white"print#w.g,"boxfilled ";x;" ";y
#w.g,"goto 50 400"#w.g,"down"
x=int(rnd(1)*450)+100:y=350print#w.g,"backcolor blue"print#w.g,"box ";x;" ";y
print#w.g,"boxfilled ";x;" ";y
print#w.g,"flush"
cm =(x-50)/50
i =2
rounded =int(cm*10^i +0.5)/10^i
wait'*************************************************'allow guess and compare with actual length of bar'*************************************************[entered]#w.tb1 "!contents? reply$"
guess =val( reply$)if( rounded -0.1<guess)and( rounded +0.1>guess)then#w.tb1 "GOOD ANSWER"else#w.tb1 "The correct answer was "; rounded; " cm, not "; guess
endiftimer3000,[continue]wait[continue]'<- when time is up, execution branches heretimer0#w.s "Measurement # "; b+1#w.tb1 ""#w.tb1 "!setfocus"'*************************************************'write to file'*************************************************[save]open"g:\record.txt"forappendas#1'create a new file on diskprint#1, guess;",";rounded
close#1next b
[grade]open"g:\record.txt"forinputas#2
correct =0whileeof(#2)=0input#2, guess, rounded
IF rounded - .1 < guess AND rounded + .1 > guess THEN
correct = correct +1ELSE
correct = correct
ENDIFwend#w.tb1 "% correct = ";(correct/5)*100timer3000,[finish]wait[finish]'<- when time is up, execution branches heretimer0[quit]close#2close#w
end
I got some more help from the LB forum guys to put together this program. It allows the user to read and input the observed length of a rectangle. It gives the user 5 different rectangles to measure and it gives instant feedback as well as it saves a copy of the results to a file. Caution on the use of the program. Make sure that the file address is suitable for your computer. I worked off of a jump drive so the file was opened, written to, and saved on the g:\ drive. If you are working only on your c:\ drive or some other drive, please change the file address code in the program to reflect the drive to which you are using to save the results. *
Otherwise, it is a straightforward program
code