WeBWorKdocs

sq_webwork:


Home
Current UR
courses
Visitor
page
Intro to
WeBWorK
WeBWorK 2
Twiki
WW
Community
Grant Support
& awards
Discussion
group
Problem
library
Write/modify
problems
Create &
manage course
Tutorial on
running a course
HowTos
FAQ
WeBWorK2
FAQ
Software
Download
How to
Install WW server
Feedback
Site Map
Change
preferences
Change
password





Prev | Next | tutorial

This page is no longer being maintained. The new URL for this content is http://webwork.maa.org/wiki/JavaApplets

The Java applet example

To obtain this problem

(1 pt) rochesterLibrary/setMAAtutorial/javaappletexample.pg

Java applet example

This problem illustrates how you can embed Java applet code in a WeBWorK example to create an interactive homework problem that could never be provided by a text book.

WeBWorK can use existing javaScript and Java code to augment its capabilities.


mathbean applet from David Ecks

The graph above represents the function

f(x) = x^2 + a x +b
where a and b are parameters.

For each value of a find the value of b which makes the graph just touch the x-axis.
if a= 2 then
if a= -0.5 then
if a= -2.5 then

Does this relationship between a and b specify b as a function of a? (Yes or No)
Does this relationship between a and b specify a as a function of b? (Yes or No)
Write a formula for calculating this value of b from a.
b =


WARNINGS
µ¦å{h­
Enter this code {viewSource(setMAAtutorial/javaappletexample.pg)}

DOCUMENT();

loadMacros(PG.pl, PGbasicmacros.pl, PGchoicemacros.pl, PGanswermacros.pl ); TEXT(beginproblem()); $javaApplet = <<EOF; < applet code="mathbeans.SliderGraphApplet.class" archive="/applets/mathbeans.jar" codebase="../classes/" width=480 height=380> < PARAM NAME="variable1" VALUE="a"> < PARAM NAME="variable2" VALUE="b"> < param name="function" value="x^2 +a*x +b"> < param name="limits" value="-2 2 -9 9"> </applet> < H6><A HREF="http://math.hws.edu/mathbeans/applets/index.html">mathbean applet from David Ecks </A> </H6> EOF

TEXT(MODES( TeX => " \fbox{ The java applet was displayed here}", Latex2HTML => "\begin{rawhtml} $javaApplet \end{rawhtml}", HTML_tth => $javaApplet, HTML => $javaApplet, ));

$a1= random(-3,3,.5); $a2= random(-3,3,.5); $a3= random(-3,3,.5); $b1 =($a1/2)**2; ANS( num_cmp( $b1, reltol => 10, format=>'%0.2g')); ANS( num_cmp( $b2,reltol => 10, format=>'%0.2g')); ANS( num_cmp( $b3, reltol => 10,format=>'%0.2g')); BEGIN_TEXT $PAR The graph above represents the function \[f(x) = x^2 + a x +b \] where \( a \) and \( b \) are parameters. $PAR

For each value of \( a \) find the value of \( b \) which makes the graph just touch the x-axis. $BR if a= $a1 then \{ ans_rule(10) \}$BR if a= $a2 then \{ ans_rule(10) \}$BR if a= $a3 then \{ ans_rule(10) \} $PAR Does this relationship between a and b specify b as a function of a? \{ ans_rule(4) \} (Yes or No)$BR Does this relationship between a and b specify a as a function of b? \{ ans_rule(4) \} (Yes or No)$BR Write a formula for calculating this value of \( b \) from \( a \).$BR b = \{ ans_rule(40) \} END_TEXT ANS(str_cmp('Yes') ); ANS(str_cmp('No') ); ANS(function_cmp( '(a/2)^2', 'a') ); ENDDOCUMENT();


Comments:

This problem is just a demo -- it doesn't actually work if you push the submit answer button. (You can test a {linkWebworkProblem("tutorialCourse", "setFirstSteps","10","live")} version of this problem.)


Prev | Next | tutorial

Last update: Monday, March 3, 2008 at 6:27:30 PM.
This site maintained using Manila and Frontier software.