Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,44 @@
## KEYWORDS('algebra,absolute value')

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"AnswerFormatHelp.pl",
"contextLimitedRadical.pl",
'PGstandard.pl', 'PGML.pl',
'contextLimitedRadical.pl', 'PGcourse.pl'
);
Context("Numeric");

# Define variables here:

$a = list_random(2,3,5,7);
do {$b = list_random(2,3,5,7);} until ($b != $a);

$c = ceil(sqrt($a));
$d = floor(sqrt($b));

Context("LimitedRadical");
Context()->functions->disable("abs");
Context()->parens->remove("|");
Context()->{error}{convert} = sub {
my $message = shift;
$message =~ s/Unexpected character '~~|'/You cannot use absolute value/;
return $message;
my $message = shift;
$message =~ s/Unexpected character '~~|'/You cannot use absolute value/;
return $message;
};

# Define variables here:

$a = list_random(2, 3, 5, 7);
do { $b = list_random(2, 3, 5, 7); } until ($b != $a);

$c = ceil(sqrt($a));
$d = floor(sqrt($b));

$dif1 = Formula("$c - sqrt($a)");
$dif2 = Formula("$d - sqrt($b)");

$ans1 = Formula("$c - sqrt($a)");
$ans2 = Formula("sqrt($b) - $d");

# Actual problem goes here:
TEXT(beginproblem());
BEGIN_PGML
Write each of the following numbers without using absolute value:

1. [`\left| [$dif1] \right| = `] [_________]{$ans1}

2. [`\left| [$dif2] \right| = `] [_________]{$ans2}

([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*)

[@ helpLink('formula') @]*
END_PGML

# Solution:
Expand Down
45 changes: 20 additions & 25 deletions Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,54 @@
## KEYWORDS('algebra,absolute value')

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"AnswerFormatHelp.pl",
"answerHints.pl",
);

loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');

Context("Numeric");
Context()->functions->disable("abs");
Context()->parens->remove("|");
Context()->{error}{convert} = sub {
my $message = shift;
$message =~ s/Unexpected character '~~|'/You cannot use absolute value in this problem/;
return $message;
my $message = shift;
$message =~
s/Unexpected character '~~|'/You cannot use absolute value in this problem/;
return $message;
};

# Define variables here:

$a = random(1,9,1);
$a = random(1, 9);

$dir = random(0,1,1);
$ord = random(0,1,1);
$dir = random(0, 1);
$ord = random(0, 1);

$fst = Compute("$a - x");
$snd = Compute("x - $a");

if ($dir) {
$ineq = "\le";
$ans = Compute("$a - x");
$ineq = "\le";
$ans = Compute("$a - x");
} else {
$ineq = "\ge";
$ans = Compute("x - $a");
$ineq = "\ge";
$ans = Compute("x - $a");
}

if ($ord) {
$p1 = $fst;
$p2 = $snd;
$p1 = $fst;
$p2 = $snd;
} else {
$p1 = $snd;
$p2 = $fst;
$p1 = $snd;
$p2 = $fst;
}

# Actual problem goes here:
TEXT(beginproblem());
BEGIN_PGML
Write each of the following numbers without using absolute value, given that [` x [$ineq] [$a] `]:

1. [`\left| [$p1] \right| = `] [_________]{$ans}

2. [`\left| [$p2] \right| = `] [_________]{$ans}

([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*)

[@ helpLink('formula') @]*
END_PGML

# Solution:
Expand Down
22 changes: 7 additions & 15 deletions Contrib/SVSU/College_Algebra/absolute_values/distance1.pg
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,17 @@
## KEYWORDS('algebra,absolute value')

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"AnswerFormatHelp.pl",
"answerHints.pl",
);

loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Context("Numeric");

# Define variables here:

$a = random(1,9,1);
$b = random($a+1,15,1); # $a < $b
$a = random(1, 9, 1);
$b = random($a + 1, 15, 1); # $a < $b

$c = random(7, 18, 1);
$d = random(2,$c-1,1); # $c > $d
$c = random(7, 18, 1);
$d = random(2, $c - 1, 1); # $c > $d

$ans1 = Compute("$b - $a");
$ans2 = Compute("$c - $d");
Expand All @@ -43,8 +37,6 @@ $ans4 = Compute("$d - x");

$ans5 = Compute("|x - $b|");

# Actual problem goes here:
TEXT(beginproblem());
BEGIN_PGML
This problem is about the _distance between numbers on the number line_.

Expand All @@ -69,7 +61,7 @@ This problem is about the _distance between numbers on the number line_.

[_________]{$ans5}

([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*)
[@ helpLink('formula') @]*
END_PGML

# Solution:
Expand Down
114 changes: 53 additions & 61 deletions Contrib/SVSU/College_Algebra/applied_problems/interest.pg
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,48 @@
## Level(5)
## KEYWORDS('algebra', 'application problems', 'mixing problems')


###########################
# Initialization

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGcourse.pl",
"unionTables.pl",
"PGML.pl",
"scaffold.pl",
'PGstandard.pl', 'PGML.pl', 'randomPerson.pl', 'scaffold.pl',
'PGcourse.pl'
);

TEXT(beginproblem());
$showPartialCorrectAnswers=1;

###########################
# Setup

Context("Numeric")->variables->are(x=>"Real");
Context("Numeric")->variables->are(x => "Real");

## names and pronouns:

$sex = list_random("he","she");
$person = randomPerson();

if ($sex eq "he") {
$name = list_random("John", "Darquese", "Sven", "Deleon", "Khulai", "Timbo", "Gerain");
} else {
$name = list_random("Tawni", "Monisha", "Angelique", "Samantha", "Grauni", "Khianna");
}
# $sex = list_random("he","she");

$p1 = random(4,16,1);
do { $p2 = random(4,16,1); } until (abs($p2 - $p1) > 1);
# if ($sex eq "he") {
# $name = list_random("John", "Darquese", "Sven", "Deleon", "Khulai", "Timbo", "Gerain");
# } else {
# $name = list_random("Tawni", "Monisha", "Angelique", "Samantha", "Grauni", "Khianna");
# }

$pm = min($p1,$p2);
$pM = max($p1,$p2);
$p1 = random(4, 16);
do { $p2 = random(4, 16); } until (abs($p2 - $p1) > 1);

$pm = min($p1, $p2);
$pM = max($p1, $p2);

$pdiff = $pM - $pm;

$k = random(3,20,1);
$k = random(3, 20, 1);

$total = 100*$k*$pdiff;
$total = 100 * $k * $pdiff;

$f = random($pm*$k + 1, $pM*$k - 1, 1);
$f = random($pm * $k + 1, $pM * $k - 1, 1);

$interest = $f*$pdiff;
$interest = $f * $pdiff;

$x = Compute("($interest*100 - $p2*$total)/($p1 - $p2)");

Expand All @@ -73,14 +67,12 @@ $answer8 = Compute("$interest");
# Main text

BEGIN_PGML
>> ----{100px} <<

>> [$name] wants to invest $[$total]. There are two different accounts in which [$sex] can invest: first one pays [$p1]% simple
interest, while the second one pays [$p2]% simple interest. How much should [$sex] invest into each account so that
the resulting annual interest will be exactly $[$interest]? <<
[$person] wants to invest $[$total]. There are two different accounts in which
[$person->they] can invest: first one pays [$p1]% simple
interest, while the second one pays [$p2]% simple interest. How much should
[$person->they] invest into each account so that
the resulting annual interest will be exactly $[$interest]?


>> ----{100px} <<
END_PGML

Scaffold::Begin(
Expand All @@ -90,40 +82,33 @@ Scaffold::Begin(

Section::Begin("Part 1: Set up the table");

$table1 =
BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1).
AlignedRow(["Account","Interest rate","Amount invested","Interest"], align=>CENTER, separation=>0).
AlignedRow(["First",ans_rule(10),ans_rule(10),ans_rule(10)], separation=>0).
AlignedRow(["Second",ans_rule(10),ans_rule(10),ans_rule(10)], separation=>0).
AlignedRow(["Total (given)"," ",ans_rule(10),ans_rule(10)], separation=>0).
EndTable();

$table2 =
BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1).
AlignedRow(["Account","Interest rate","Amount invested","Interest"], align=>CENTER, separation=>0).
AlignedRow(["First",$answer1,$answer2,$answer3], separation=>0).
AlignedRow(["Second",$answer4,$answer5,$answer6], separation=>0).
AlignedRow(["Total (given)"," ",$answer7,$answer8], separation=>0).
EndTable();

BEGIN_PGML
First, fill in the following table, using [`x`] for the amount invested in the first account.

[$table1]*
[#
[.Account .]
[.Interest rate .]
[.Amount invested .]
[.Interest .]{headerrow=>1}*
[.First .]
[.[_]{$answer1}{10} .]
[.[_]{$answer2}{10} .]
[.[_]{$answer3}{10} .]*
[.Second .]
[.[_]{$answer4}{10} .]
[.[_]{$answer5}{10} .]
[.[_]{$answer6}{10} .]*
[.Total (given) .]
[. .]
[.[_]{$answer7}{10} .]
[.[_]{$answer8}{10} .]*
#]{horizontalrules => 1, texalignment => '|c|c|c|c|', padding=> 0.3}


END_PGML

############################
# Answer evaluation
[$table1]*

ANS( $answer1->cmp() );
ANS( $answer2->cmp() );
ANS( $answer3->cmp() );
ANS( $answer4->cmp() );
ANS( $answer5->cmp() );
ANS( $answer6->cmp() );
ANS( $answer7->cmp() );
ANS( $answer8->cmp() );
END_PGML

BEGIN_PGML_SOLUTION
The first column of the table is easy to fill in, just put down the rate of
Expand All @@ -137,13 +122,20 @@ rate times quantity).

The table will look like this:

[#
[.Account .] [.Interest rate.] [.Amount invested.] [.Interest.]{headerrow=>1}*
[.First .] [.[$answer1] .] [.[$answer2] .] [.[$answer3] .]*
[.Second .] [.[$answer4] .] [.[$answer5] .] [.[$answer6] .]*
[.Total (given) .] [. .] [.[$answer7] .] [.[$answer8] .]*
#]{horizontalrules => 1, texalignment => '|c|c|c|c|', padding=> 0.3}


[$table2]*

END_PGML_SOLUTION

Section::End();

###########################################
Section::Begin("Part 2: Solve the equation");

BEGIN_PGML
Expand Down
Loading