# Ethan Windsor & Lauren Prew # Minimize the Surface Area of a Box # Math 152 - Section 201 restart: with(Maplets[Tools]): with(Maplets[Elements]): StartEngine(); randomize(): lightorange:="#FFB300": lightcyan:="#DDFFFF": ColorFooter:=lightcyan: FontFooter:=Font("helvetica",10): randL:=rand(1..10): problem:=proc() global areaw, mwid, mhgt; local vol, hgt, plotlist, plotlist2, R, canplot; areaw:=w^2+4*vol/w; mwid:=2*randL(); vol:=mwid^3/2; Set(mliter=vol); mhgt:=mwid/2; Set(TFarea=""); Set(TFvolume=""); Set(TFareaw=""); Set(TFmwid=""); Set(TFmhgt=""); Set(reply=""); end proc: hint1:=proc() Set(reply="Add the area of the base and the area of the sides."): end proc: check1:=proc() local user_area; if Get(TFarea)="" then Set(reply="No answer given."); return; end if; user_area:=Get(TFarea::anything): if simplify(4*w*h+w^2 - user_area)=0 then Set(reply="Correct."): else Set(reply="Incorrect."): end if; end proc: show1:=proc() Set(TFarea="w^2+4*w*h"): end proc: hint2:=proc() Set(reply="Multiply the area of the base by the height."): end proc: check2:=proc() local user_volume; if Get(TFvolume)="" then Set(reply="No answer given."); return; end if; user_volume:=Get(TFvolume::anything): if simplify(w^2*h - user_volume)=0 then Set(reply="Correct."): else Set(reply="Incorrect."): end if; end proc: show2:=proc() Set(TFvolume="w^2*h"): end proc: hint3:=proc() Set(reply="Use the volume constraint to eliminate the variable h."): end proc: check3:=proc() global areaw; local user_areaw; if Get(TFareaw)=""then Set(reply="No answer given."); return; end if; user_areaw:=Get(TFareaw::anything): if simplify(areaw - user_areaw=0) then Set(reply="Correct."): else Set(reply="Incorrect."): end if; end proc: show3:=proc() global areaw; Set(TFareaw=areaw): end proc: hint4:=proc() Set(reply="Find the minimum width by setting the derivative of the surface area equal to zero."): end proc: check4:=proc() global mwid; local user_mwid; if Get(TFmwid)="" then Set(reply="No answer given."); return; end if; user_mwid:=Get(TFmwid::anything): if simplify(mwid - user_mwid=0) then Set(reply="Correct."): else Set(reply="Incorrect."): end if; end proc: show4:=proc() global mwid; Set(TFmwid=mwid): end proc: hint5:=proc() Set(reply="Plug the minimum width into the volume constraint."): end proc: check5:=proc() global mhgt; local user_mhgt; if Get(TFmhgt)="" then Set (reply="No answer given."); return; end if; user_mhgt:=Get(TFmhgt::anything): if simplify(mhgt - user_mhgt=0) then Set (reply="Correct."): else Set (reply="Incorrect."): end if; end proc: show5:=proc() global mhgt; Set(TFmhgt=simplify(mhgt)): end proc: MinAreaBox:=Maplet(onstartup=RunWindow(MAIN), Window[MAIN](title="Minimize the Surface Area of a Box", [ halign=none, [ Button("New Problem", Evaluate(function=problem), background=magenta), HorizontalGlue(), Button("Quit", Shutdown(), background=pink) ], [ "A box with a square base, open top, and volume V =", TextField[mliter](width=6,editable=false, background=white), "cm^3 is being constructed.", HorizontalGlue() ], [ "Determine the dimensions (height h and width w) of the box with minimum surface area.", HorizontalGlue() ], [ border=true, caption="Enter the Formula for the Surface Area of a box with a square base:", "A =", TextField[TFarea](width=17, background=turquoise), HorizontalGlue(), Button("Hint", Evaluate(function="hint1"), background=lightorange), Button("Check", Evaluate(function="check1"), background=green), Button("Show", Evaluate(function="show1"), background=lightorange) ], [ border=true, caption="Enter the Formula for the Volume of a box with a square base:", "V =", TextField[TFvolume](width=17, background=turquoise), HorizontalGlue(), Button("Hint", Evaluate(function="hint2"), background=lightorange), Button("Check", Evaluate(function="check2"), background=green), Button("Show", Evaluate(function="show2"), background=lightorange) ], [ border=true, caption="Express the Surface Area in terms of w:", "A =", TextField[TFareaw](width=17, background=turquoise), HorizontalGlue(), Button("Hint", Evaluate(function="hint3"), background=lightorange), Button("Check", Evaluate(function="check3"), background=green), Button("Show", Evaluate(function="show3"), background=lightorange) ], [ border=true, caption="Find the w which gives Minimum Area:", "w =", TextField[TFmwid](width=17, background=turquoise), "cm", HorizontalGlue(), Button("Hint", Evaluate(function="hint4"), background=lightorange), Button("Check", Evaluate(function="check4"), background=green), Button("Show", Evaluate(function="show4"), background=lightorange) ], [ border=true, caption="Find the h which gives Minimum Area:", "h =", TextField[TFmhgt](width=17, background=turquoise), "cm", HorizontalGlue(), Button("Hint", Evaluate(function="hint5"), background=lightorange), Button("Check", Evaluate(function="check5"), background=green), Button("Show", Evaluate(function="show5"), background=lightorange) ], [ halign=none, TextField[reply](width=40, editable=false, background=white) ], [ halign=none, background=ColorFooter, Label("Programmers: Ethan Windsor & Lauren Prew", font=FontFooter), HorizontalGlue(), Label("Copyright: P. Yasskin 2008", font=FontFooter) ] ] ) ): Maplets[Display]( MinAreaBox );