restart: with(Maplets): with(Maplets[Tools]): with(Maplets[Elements]): StartEngine(); randomize(): SolveLogEq:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN]('title'="Solving Logarithmic Equations", [ halign=none, [ Button("New Equation", Evaluate(function="new")), HorizontalGlue(), Button("Quit",Shutdown()) ], [ "Solve the following logarithmic equation for x.", HorizontalGlue() ], [ MathMLViewer['MMLV1'](width=300, height=50) ], [ "Select:", HorizontalGlue(), RadioButton[RBsol0]("0 solutions", false, group=BG1), RadioButton[RBsol1]("1 solution", false, group=BG1), RadioButton[RBsol2]("2 solutions", false, group=BG1), HorizontalGlue() ], [ HorizontalGlue(), Label[Lx1]("x="), TextField['answer1']('width'=5), Label[Lx2]("x="), TextField['answer2']('width'=5), HorizontalGlue() ], [ Button("Check", Evaluate('function'= "check")), Button("Show", Evaluate('function'="show")) ], [ TextField['reply']('width'=40, 'editable'='false') ], [ "Programmer: Tate", HorizontalGlue(), "Copyright P. Yasskin 2005" ] ] ), ButtonGroup[BG1](onchange=Evaluate(function="numsol")) ): new:=proc() local rand12,rand19,q,r,Q,R,P,A,B,C,eqn,sol; global nsols,correctanswer1,correctanswer2; rand12:=rand(1..2); rand19:=rand(1..9); q:=rand12(); r:=rand12(); Q:=(-1)^q*rand19(); R:=(-1)^r*rand19(); P:=(-1)^(q+r+1)*rand19(); A:=P; B:=-(Q+R); C:=-P*Q*R; eqn:=log(A*x)+log(x+B)=log(C); sol:=solve(eqn,x); nsols:=nops([sol]); if nsols=2 then correctanswer1:=sol[1]; correctanswer2:=sol[2]; elif nsols=1 then correctanswer1:=sol; correctanswer2:=NULL; else correctanswer1:=NULL; correctanswer2:=NULL; end if; Set('MMLV1'=MathML[Export](eqn)); Set('RBsol0'=false); Set('RBsol1'=false); Set('RBsol2'=false); Set(answer1="", answer1(visible)=false); Set(answer2="", answer2(visible)=false); Set(Lx1(visible)=false); Set(Lx2(visible)=false); Set(reply=""); end proc: numsol:=proc() global user_nsols; if Get('RBsol2'::truefalse) then user_nsols:=2; Set(answer1(visible)=true); Set(answer2(visible)=true); Set(Lx1(visible)=true); Set(Lx2(visible)=true); elif Get('RBsol1'::truefalse) then user_nsols:=1; Set(answer1(visible)=true); Set(answer2="", answer2(visible)=false); Set(Lx1(visible)=true); Set(Lx2(visible)=false); elif Get('RBsol0'::truefalse) then user_nsols:=0; Set(answer1="", answer1(visible)=false); Set(answer2="", answer2(visible)=false); Set(Lx1(visible)=false); Set(Lx2(visible)=false); else Set(reply="You need to select a radio button to indicate the number of solutions."); end if; end proc: check:=proc() local user_answer1, user_answer2: global nsols, user_nsols, correctanswer1, correctanswer2: user_answer1:=Get('answer1'::anything); user_answer2:=Get('answer2'::anything); if user_nsols<>nsols then Set('reply'="You do not have the correct number of solutions."); return end if; if {user_answer1, user_answer2} = {correctanswer1, correctanswer2} then Set('reply'="Correct"); else Set('reply'="Incorrect"); end if; end proc: show:=proc() global nsols, user_nsols, correctanswer1, correctanswer2: if correctanswer1=NULL then Set('answer1'=""); else Set('answer1'=correctanswer1); end if; if correctanswer2=NULL then Set('answer2'=""); else Set('answer2'=correctanswer2); end if; Set(reply=""); if nsols=2 then Set('RBsol2'=true); user_nsols:=2; Set(answer1(visible)=true); Set(answer2(visible)=true); Set(Lx1(visible)=true); Set(Lx2(visible)=true); elif nsols=1 then Set('RBsol1'=true); user_nsols:=1; Set(answer1(visible)=true); Set(answer2="", answer2(visible)=false); Set(Lx1(visible)=true); Set(Lx2(visible)=false); elif nsols=0 then Set('RBsol0'=true); user_nsols:=0; Set(answer1="", answer1(visible)=false); Set(answer2="", answer2(visible)=false); Set(Lx1(visible)=false); Set(Lx2(visible)=false); else Set(reply="You need to click on New Equation."); end if; end proc: Display(SolveLogEq);