[npl] / trunk / NationalProblemLibrary / LoyolaChicago / Precalc / Chap2Sec1 / Connally3-2-1-25-Input-and-output.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/NationalProblemLibrary/LoyolaChicago/Precalc/Chap2Sec1/Connally3-2-1-25-Input-and-output.pg

Tue Jun 26 00:57:10 2012 UTC (10 months, 3 weeks ago) by pearson
File size: 4703 byte(s)
`Changed the second multiple choice answer checker from \$mca to \$mcb`

```    1 ## DESCRIPTION
2 ## Functions: Input and Output
3 ## ENDDESCRIPTION
4
5 ## KEYWORDS('functions','evaluating','solving','input','output')
6
7 ## DBsubject('Precalculus')
8 ## DBchapter('Functions')
9 ## DBsection('Input and Output')
10 ## Date('01/01/10')
11 ## Author('Paul Pearson')
12 ## Institution('Fort Lewis College')
13 ## TitleText1('Functions Modeling Change')
14 ## EditionText1('3')
15 ## AuthorText1('Connally')
16 ## Section1('2.1')
17 ## Problem1('25')
18 ## TitleText2('Functions Modeling Change');
19 ## EditionText2('4')
20 ## AuthorText2('Connally')
21 ## Section2('2.Review')
22 ## Problem2('51')
23
24 DOCUMENT();
25
27 "PGstandard.pl",
28 "PGchoicemacros.pl",
29 "MathObjects.pl",
31 "PGcourse.pl",
32 );
33
34 TEXT(beginproblem());
35
36 ###############################################
37 #  Setup
38
39 @month = (1 .. 8);
40 @monthname = ("blank", # since indexing starts at 0
41 "January","February","March",
42 "April","May","June",
43 "July","August","September",
44 "October","November","December"
45 );
46
47 @rainfall = ( 1.8, 1.8, 2.7, 3.1, 3.5, 3.7, 3.5, 3.4 );
48 # @perm = shuffle(scalar(@rainfall));
49 # @invperm = invert(@perm);
50 # @rainfallperm = @rainfall[@perm];
51
52 ############
53 #  Part A
54 #
55 \$selecta = random(0,3,1);
56 # indices for months 3=March, 4=April, 6=June and 8=August in @rainfall
57 @parta = (2,3,5,7);
58 \$raina = @rainfall[\$parta[\$selecta]];
59
62
63 \$dummy = random(1,8,1);
64 while (\$dummy == \$answera) { \$dummy = random(1,8,1); }
65
66 \$mca = new_multiple_choice();
67 \$mca -> qa(
68 "The solution(s) to \( f(t) = \$raina \) can be interpreted as saying",
69 "Chicago's average rainfall in the month of @monthname[\$answera] is \$raina inches."
70 );
71 \$mca -> extra(
72 "Chicago's average rainfall is greatest in the month of @monthname[\$dummy].",
73 "Chicago's average rainfall is least in the month of @monthname[\$answera].",
74 "Chicago's average rainfall increases by \$raina inches in the month of @monthname[\$dummy]."
75 );
76 \$mca -> makeLast("None of the above");
77
78
79 ############
80 #  Part B
81 #
82 \$selectb = random(0,1,1);
83 if (\$selectb == 0) {
84 @partb = (0,1); # indices for months 1=January, 2=February in @rainfall
85 } else {
86 @partb = (4,6); # indices for months 5=May, 7=July in @rainfall
87 }
88 # \$inputb1 = @month[\$invperm[\$partb[\$selectb]]];
89 # \$inputb2 = @month[\$invperm[\$partb[\$selectb-1]]];
90 (\$inputb1, \$inputb2) = num_sort( \$month[\$partb[\$selectb]],
91          \$month[\$partb[\$selectb-1]] );
92
93 \$rainb = \$rainfall[\$partb[\$selectb]];;
94
95 \$mcb = new_multiple_choice();
96 \$mcb -> qa(
97 "The solution(s) to \( f(t) = f(\$inputb1) \) can be interpreted as saying",
98 "Chicago's average rainfall is \$rainb inches in the months of @monthname[\$inputb1] and @monthname[\$inputb2]."
99 );
100 \$mcb -> extra(
101 "Chicago's average rainfall is \$rainb inches in the month of @monthname[\$inputb1].",
102 "Chicago's average rainfall is \$rainb inches in the month of @monthname[\$inputb2].",
103 "Chicago's average rainfall is greatest in the month of @monthname[\$inputb1].",
104 );
105 \$mcb -> makeLast("None of the above");
106
107
108
109 ##################################################
110 #  Main text
111
112 # for debugging, use this table
113 #\{ row( "t, month", @month ) \}
114 #\{ row( "t, month", @month[@invperm] ) \}
115 #\{ row( "R, inches", @rainfall ) \}
116 #\{ row( "R, inches", @rainfall[@perm] ) \}
117
118 Context()->texStrings;
119 BEGIN_TEXT
120
121 Chicago's average monthly rainfall, \( R = f(t) \) inches,
122 is given as a function of the month, \( t \), where January
123 is \( t = 1 \), in the table below.
124 \$BR
125 \$BCENTER
126 \{ begintable(13) \}
127 \{ row( "t, month", @month ) \}
128 \{ row( "R, inches", @rainfall ) \}
129 \{ endtable() \}
130 \$ECENTER
131 \$BR
132 (a) Solve \( f(t) = \$raina \).
133 \$BR
134 \( t = \) \{ ans_rule(10) \}
136 \$PAR
137 \{ \$mca->print_q() \}
138 \{ \$mca->print_a() \}
139 \$BR
140 (b) Solve \( f(t) = f(\$inputb1) \).
141 \$BR
142 \( t = \) \{ ans_rule(10) \}
144 \$PAR
145 \{ \$mcb->print_q() \}
146 \{ \$mcb->print_a() \}
147
148 END_TEXT
149 Context()->normalStrings;
150
151 #################################################
153
155
157
159
160 ANS(List(Real("\$inputb1"),Real("\$inputb2"))->cmp());
161
163
164 \$tb1 = \$partb[0]+1;
165 \$tb2 = \$partb[1]+1;
166
167 Context()->texStrings;
168 SOLUTION(EV3(<<'END_SOLUTION'));
169 \$PAR
170 \$BBOLD SOLUTION \$EBOLD
171 \$PAR
173 Chicago's average rainfall in the month of @monthname[\$answera]
174 is \$raina inches.
175 \$PAR
176 (b) First evaluate \(f(\$partb[0])=\$rainb\). Solving \(f(t)=\$rainb\) gives
177 \(t=\$tb1\) or \(t=\$tb2\). Chicago's average rainfall is \$rainb inches in
178 @monthname[\$inputb1] and @monthname[\$inputb2].
179
180 END_SOLUTION
181 Context()->normalStrings;
182
183 COMMENT('MathObject version');
184 ENDDOCUMENT();
```