restart: with(Maplets[Tools]): with(Maplets[Elements]): with(plots): StartEngine(); FindSlope:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN](title="Slopes of Lines", [ [ Button("Ask Question", Evaluate(function = "ask")), " ", Button("Quit", Shutdown()) ], [ TextField[question](width=40, editable=false) ], [ "Answer: ", TextField[answer](width=25), Button("Check Answer", Evaluate(function = "check")) ], [ TextField[reply](width=40, editable=false) ] ] ) ): ask:=proc() global correctslope; local a,b,c,d, rand5; rand5:=rand(-5..5): a:=rand5(); b:=rand5(); c:=rand5(); d:=rand5(); while (a=c or b=d) do c:=rand5(); d:=rand5(); end do; correctslope:=(d-b)/(c-a); Set(question=cat( "Find the slope of the line through the points (", substring(convert([a,b],string),2..-2), ") and (", substring(convert([c,d],string),2..-2), ")." )) end proc: check:=proc() global correctslope; local userslope; userslope:=Get(thismaplet,answer::realcons): if userslope=correctslope then Set(reply="Correct! Try another question.") else Set(reply="Incorrect. Try again.") end if; end proc: Maplets[Display]( FindSlope );