##DESCRIPTION
## Missouri Western State University, Finite Mathematics Homework
##ENDDESCRIPTION
##KEYWORDS('Finite Mathematics', 'Linear Equations', 'MWSU')
## DBsubject('Finite Mathematics')
## DBchapter('Linear Equations and Inequalities')
## DBsection('Inequalities in One Variable')
## Date('09/07/2014')
## Author('Glenn Rice')
## Institution('Missouri Western State University')
## ProblemTester('')
## TitleText1('Finite Math')
## Publisher('')
## EditionText1('1')
## AuthorText1('Rice, Klassen, Hegeman')
## Section1('1.2')
## Problem1('12')
################################################################################################
# Setup and Macros
################################################################################################
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"problemRandomize.pl"
);
################################################################################################
# Variables, Formulas, and Graphs
################################################################################################
TEXT(beginproblem());
Context("Point");
$x1 = random(-10, 9);
$x2 = random($x1 + 1, 10); # TODO: Allow vertical lines
$y1 = random(-10, 10);
$y2 = random(-10, 10);
$slope = Compute("($y2 - $y1) / ($x2 - $x1)");
$yint = Compute("$y1 - $slope * $x1");
$answer = Compute("($slope,$yint)");
# Custom answer checker that checks to see if a point is on the line
sub point_on_line
{
my ($correct, $student, $ansHash) = @_;
my ($m, $b) = $correct->value;
my ($x, $y) = $student->value;
if (abs($y - $x * $m - $b) < 0.2) { return 1; }
Value->Error("The point graphed is not on the line");
return 0;
}
################################################################################################
# Main Text
################################################################################################
Context()->texStrings;
Context()->operators->undefine("+","-","*","/");
HEADER_TEXT(<
A:
B:
END_TEXT NAMED_ANS('point1_coords_ans'=>$answer->cmp(checker=>~~&point_on_line)); NAMED_ANS('point2_coords_ans'=>$answer->cmp(checker=>~~&point_on_line)); ENDDOCUMENT();