Susan Vanderzyl, Rebecca HollkampMath 152 - Section 201Tin Can Problemrestart:with(Maplets): with(Maplets[Tools]): with(Maplets[Elements]): with(plots): with(plottools):
StartEngine();randomize():lightorange:="#FFB300":randL:=rand(2..20):problem:=proc()
global arear, mrad, mhgt;
local vol, hgt, plotlist, plotlist2, R, canplot;
vol:=500*randL()*Pi;
Set(mliter=vol);
arear:=2*Pi*r^2+2*vol/r;
mrad:=(vol/(2*Pi))^(1/3);
mhgt:=(vol/Pi)^(1/3)*2^(2/3);
hgt:=vol/(Pi*R^2);
plotlist:=NULL;
for R from evalf(mrad/2) by evalf(mrad/10) to evalf(2*mrad) do
plotlist:=plotlist, display(cylinder([0,0,0], R, hgt, color=gray));
end do:
plotlist2:=op(ListTools[Reverse]([plotlist]));
canplot:=display([plotlist,plotlist2], axes=normal, tickmarks=[3,3,3], scaling=constrained, insequence=true);
Set(CanPlot=canplot);
Set(TFarea="");
Set(TFvolume="");
Set(TFarear="");
Set(TFmrad="");
Set(TFmhgt="");
Set(reply="");
end proc:hint1:=proc()
Set(reply="Add the area of the two bases 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(2*Pi*r*h + 2*Pi*r^2 - user_area)=0 then
Set(reply="Correct."):
else
Set(reply="Incorrect."):
end if;
end proc:show1:=proc()
Set(TFarea=" 2*Pi*r*h + 2*Pi*r^2"):
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(Pi*r^2*h - user_volume)=0 then
Set(reply="Correct."):
else
Set(reply="Incorrect."):
end if;
end proc:show2:=proc()
Set(TFvolume=" Pi*r^2*h"):
end proc:hint3:=proc()
Set(reply="Use the volume constraint to eliminate the variable h."):
end proc:check3:=proc()
global arear;
local user_arear;
if Get(TFarear)=""then
Set(reply="No answer given.");
return;
end if;
user_arear:=Get(TFarear::anything):
if simplify(arear - user_arear=0) then
Set(reply="Correct."):
else
Set(reply="Incorrect."):
end if;
end proc:show3:=proc()
global arear;
Set(TFarear=arear):
end proc:hint4:=proc()
Set(reply="Find the minimum radius by setting the derivative of the area equal to zero."):
end proc:check4:=proc()
global mrad;
local user_mrad;
if Get(TFmrad)="" then
Set(reply="No answer given.");
return;
end if;
user_mrad:=Get(TFmrad::anything):
if simplify(mrad - user_mrad=0) then
Set(reply="Correct."):
else
Set(reply="Incorrect."):
end if;
end proc:show4:=proc()
global mrad;
Set(TFmrad=mrad):
end proc:hint5:=proc()
Set(reply="Plug the minimum radius 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:LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnMaxCan:=Maplet(onstartup=RunWindow(MAIN),
Font[helv10]("helvetica",10),
Window[MAIN](title="Max/Min",
[ [ Button("New Problem", Evaluate(function=problem), background=magenta),
Button("Quit", Shutdown(), background=pink)
],
[ border=true,
"A can is made to hold",
TextField[mliter](width=6, editable=false, background=white),
"mL of oil. Find the height h and radius r that will minimize the cost of metal to make the can."
],
[ halign=none, inset=0, spacing=0,
[ halign=none, inset=0, spacing=0,
[ border=true,
caption="Enter the Formula for the Surface Area of a Cylinder:",
"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 Cylinder:",
"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 r:",
"A =",
TextField[TFarear](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 Radius which gives Minimum Area:",
"r =",
TextField[TFmrad](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 Height 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)
]
],
[ border=true,
caption="Animation",
[ Plotter[CanPlot](width=200, height=200)
],
[ Button("Play", onclick=SetOption(CanPlot(play)=true), background=tan),
Button("Stop", onclick=SetOption(CanPlot(pause)=true), background=tan)
],
[ Button("Forward", onclick=Action(SetOption(CanPlot(pause)=true),
SetOption(CanPlot(frame_forward)=true)), background=tan),
Button("Reverse", onclick=Action(SetOption(CanPlot(pause)=true),
SetOption(CanPlot(frame_backwards)=true)), background=tan)
]
]
],
[ halign=none,
TextField[reply](width=65, editable=false, background=white)
],
[ background="#DDFFFF", inset=0, spacing=0,
Label("Programmers: Susan Vanderzyl & Rebecca Hollkamp", font=helv10),
HorizontalGlue(),
Label("Copyright P. Yasskin 2007", font=helv10)
]
]
)
):Maplets[Display]( MaxCan );