restart: with(Maplets): with(Maplets[Tools]): with(Maplets[Elements]): with(plots): StartEngine(); TrigFuncs:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN]('title'="Trigonometric Functions", [ halign=none, [ Button("New Triangle", Evaluate('function' = "ask")), HorizontalGlue(), Button("Quit", Shutdown()) ], [ valign=none, [ [ "Consider the triangle with vertices:", HorizontalGlue() ], TextBox['question']('width'=40, 'editable'='false'), VerticalGlue() ], HorizontalGlue(), Plotter['PL'](plot(0,view=[0..10,0..10], color=black), width=200,height=200), HorizontalGlue() ], [ "Compute each of the following:", HorizontalGlue() ], [ [ [ "sin(A)= ", TextField['sinA']('width'=10), Button("Check", Evaluate(function="check1")), Button("Show", Evaluate(function="ans1")) ], [ "tan(A)= ", TextField['tanA']('width'=10), Button("Check", Evaluate(function="check3")), Button("Show", Evaluate(function="ans3")) ], [ "sec(A)= ", TextField['secA']('width'=10), Button("Check", Evaluate(function="check5")), Button("Show", Evaluate(function="ans5")) ] ], [ [ "cos(A)= ", TextField['cosA']('width'=10), Button("Check", Evaluate(function="check2")), Button("Show", Evaluate(function="ans2")) ], [ "cot(A)= ", TextField['cotA']('width'=10), Button("Check", Evaluate(function="check4")), Button("Show", Evaluate(function="ans4")) ], [ "csc(A)= ", TextField['cscA']('width'=10), Button("Check", Evaluate(function="check6")), Button("Show", Evaluate(function="ans6")) ] ] ], [ Button("Check All Answers", Evaluate('function' = "checkall")) ], [ TextField['reply']('width'=40, 'editable'='false') ], [ "Programmers: Duensing & Millican Copyright P. Yasskin 2005" ] ] ) ): ask:=proc() global a, b, points,correctsin, correctcos, correcttan, correctcot, correctsec, correctcsc; local c,rand9; rand9:=rand(1..9): a:=rand9(); b:=rand9(); points:=[[0,0],[b,0],[b,a],[0,0]]; c:=sqrt(a^2+b^2); correctsin:=a/c; correctcos:=b/c; correcttan:=a/b; correctcot:=b/a; correctsec:=c/b; correctcsc:=c/a; Set('question'= cat(" A=(0,0), B=(",b,",0), and C=(",b,",",a,").") ); Set('PL'=plot(points, scaling=constrained, tickmarks=[[0,b],[0,a]])); end proc: check1:=proc() global correctsin; local usersin; usersin:=Get('sinA'::'realcons', corrections=true, update=true): if usersin=correctsin then Set('reply'="Correct! Try another question.") else Set('reply'="Incorrect. Try again.") end if; end proc: check2:=proc() global correctcos; local usercos; usercos:=Get('cosA'::'realcons', corrections=true, update=true): if usercos=correctcos then Set('reply'="Correct! Try another question.") else Set('reply'="Incorrect. Try again.") end if; end proc: check3:=proc() global correcttan; local usertan; usertan:=Get('tanA'::'realcons', corrections=true, update=true): if usertan=correcttan then Set('reply'="Correct! Try another question.") else Set('reply'="Incorrect. Try again.") end if; end proc: check4:=proc() global correctcot; local usercot; usercot:=Get('cotA'::'realcons', corrections=true, update=true): if usercot=correctcot then Set('reply'="Correct! Try another question.") else Set('reply'="Incorrect. Try again.") end if; end proc: check5:=proc() global correctsec; local usersec; usersec:=Get('secA'::'realcons', corrections=true, update=true): if usersec=correctsec then Set('reply'="Correct! Try another question.") else Set('reply'="Incorrect. Try again.") end if; end proc: check6:=proc() global correctcsc; local usercsc; usercsc:=Get('cscA'::'realcons', corrections=true, update=true): if usercsc=correctcsc then Set('reply'="Correct! Try another question.") else Set('reply'="Incorrect. Try again.") end if; end proc: checkall:=proc() global correctsin, correctcos, correcttan, correctcot, correctsec, correctcsc; local usersin,usercos,usertan,usercot,usersec,usercsc; usersin:=Get('sinA'::'realcons', corrections=true, update=true): usercos:=Get('cosA'::'realcons', corrections=true, update=true): usertan:=Get('tanA'::'realcons', corrections=true, update=true): usercot:=Get('cotA'::'realcons', corrections=true, update=true): usersec:=Get('secA'::'realcons', corrections=true, update=true): usercsc:=Get('cscA'::'realcons', corrections=true, update=true): if (usersin=correctsin and usercos=correctcos and usertan=correcttan and usercot=correctcot and usersec=correctsec and usercsc=correctcsc) then Set('reply'="Correct! Try another question.") else Set('reply'="Incorrect. Try again.") end if; end proc: ans1:=proc() global correctsin; Set(sinA=convert(correctsin,string)); end proc: ans2:=proc() global correctcos; Set(cosA=convert(correctcos,string)); end proc: ans3:=proc() global correcttan; Set(tanA=convert(correcttan,string)); end proc: ans4:=proc() global correctcot; Set(cotA=convert(correctcot, string)); end proc: ans5:=proc() global correctsec; Set(secA=convert(correctsec,string)); end proc: ans6:=proc() global correctcsc; Set(cscA=convert(correctcsc,string)); end proc: Display(TrigFuncs);