Answer is a number or formula with units
Download file: AnswerWithUnits.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'contextUnits.pl', 'PGcourse.pl');
Preamble
Load the parserNumberWithUnits.pl and parserFormulaWithUnits.pl macros.
Context('Units')->withUnitsFor('length', 'time')->variables->are(t => 'Real');
Context()->assignUnits(t => 's');
$v0 = random(16, 96, 16);
$h = Formula("(-16 t^2 + $v0 t) ft");
$v = $h->D('t');
$v1 = $v->eval(t => $v0 / 16);
$a = $v->D('t');
Setup
First select the “Units” context, allow units for “length” and “time”
in the context, and set the variable for functions in the context to be
t.
Then, assign the unit “seconds” to the variable t.
Use the differentiation operator ->D('t') to compute
the derivated, and the evaluation method ->eval() to
evaluate it as a function. All of these will now have the expect
units.
BEGIN_PGML
Suppose the height of a falling object, in feet above the ground, is given
by [`h(t) = [$h]`] for [`t \geq 0`], where time is measured in seconds.
a. What is the velocity of the object? Include units in your answer.
[_]{$v}{15}
b. What is the velocity of the object when it hits the ground? Include units in
your answer.
[_]{$v1}{15}
c. What is the acceleration of the object? Include units in your answer.
[_]{$a}{15}
Note: Use units in all answers. [@ helpLink('units') @]*
END_PGML
Statement
Give students access to help on entering units and the complete list
of units that WeBWorK understands by inserting the result of calling
helpLink('units') into the problem text.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.