######################################################################## ## DESCRIPTION ## A WeBWorK problem that asks students to construct a back to back stem and leaf display. ## WeBWorK problem written by JoAnne Taormina, ## ENDDESCRIPTION ## ## KEYWORDS('back to back', 'stem and leaf display') ## ## Author('JoAnne Taormina') ## Institution('Nassau Community College') ######################################################################## DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGgraphmacros.pl", "PGchoicemacros.pl", "unionTables.pl", "weightedGrader.pl", ); $refreshCachedImages=1; # make sure we're in the context we want Context("Numeric"); # the data @alldata = (); @row10=(); $j=0; for($i = 0; $i < 5; $i ++) { $alldata[$j]= random(100, 109, 1); $row10[$i] = $alldata[$j++]-100; } @row12=(); for($i = 0; $i < 9; $i ++) { $alldata[$j]=random(120, 129, 1); $row12[$i] = $alldata[$j++]-120; } @row13=(); for($i = 0; $i < 8; $i ++) { $alldata[$j] = random(130, 139, 1); $row13[$i] = $alldata[$j++]-130; } @row14=(); for($i = 0; $i < 7; $i ++) { $alldata[$j] = random(140, 149, 1); $row14[$i] = $alldata[$j++]-140; } @row15=(); for($i = 0; $i < 6; $i ++) { $alldata[$j] = random(150, 159, 1); $row15[$i] = $alldata[$j++]-150; } @row10=reverse num_sort(@row10); @row12=reverse num_sort(@row12); @row13=reverse num_sort(@row13); @row14=reverse num_sort(@row14); @row15=reverse num_sort(@row15); @alldata2 = (); $j=0; for($i = 0; $i < 3; $i ++) { $alldata2[$j] = random(80, 89, 1); $row8b[$i] = $alldata2[$j++]-80; } for($i = 0; $i < 3; $i ++) { $alldata2[$j] = random(90, 99, 1); $row9b[$i] = $alldata2[$j++]-90; } for($i = 0; $i < 7; $i ++) { $alldata2[$j] = random(100, 109, 1); $row10b[$i] = $alldata2[$j++]-100; } for($i = 0; $i < 8; $i ++) { $alldata2[$j] = random(110, 119, 1); $row11b[$i] = $alldata2[$j++]-110; } for($i = 0; $i < 9; $i ++) { $alldata2[$j] = random(120, 129, 1); $row12b[$i] = $alldata2[$j++]-120; } for($i = 0; $i < 5; $i ++) { $alldata2[$j] = random(130, 139, 1); $row13b[$i] = $alldata2[$j++]-130; } @row8b = num_sort(@row8b); @row9b = num_sort(@row9b); @row10b = num_sort(@row10b); @row11b = num_sort(@row11b); @row12b = num_sort(@row12b); @row13b = num_sort(@row13b); # the table data $table_start2 = begintable(21); $table_row2[0] = row("","","","","","","","","","","Stem","","","","","","","","","","",""); for ( $i = 1; $i <9; $i++ ) { $table_row2[$i] = row( ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(8),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2),ans_rule(2) ); } $table_end2 = endtable(); TEXT(beginproblem()); install_weighted_grader(); Context()->texStrings; BEGIN_TEXT Create a back to back stem and leaf display from the following two data sets. $BR$BR Put a single stem in the center column labeled $BBOLD "stem." $EBOLD Put the leaves for data set 1 in the blanks on the left of the stem, and the leaves for data set 2 in the blanks on the right of the stem. $BR$BR $BBOLD Each leaf has its own blank. $EBOLD $BR$BR Unused blanks should remain empty. $BR$BR DATA SET 1 $BR \[ $alldata[0], \ $alldata[1], \ $alldata[2], \ $alldata[3], \ $alldata[4], \ $alldata[5], \ $alldata[6], \ $alldata[7], \ $alldata[8], \ $alldata[9] \] \[ $alldata[10], \ $alldata[11], \ $alldata[12], \ $alldata[13], \ $alldata[14], \ $alldata[15], \ $alldata[16], \ $alldata[17], \ $alldata[18], \ $alldata[19] \] \[ $alldata[20], \ $alldata[21], \ $alldata[22], \ $alldata[23], \ $alldata[24], \ $alldata[25], \ $alldata[26], \ $alldata[27], \ $alldata[28], \ $alldata[29] \] \[ $alldata[30], \ $alldata[31], \ $alldata[32], \ $alldata[33], \ $alldata[34] \] $BR $BR DATA SET 2 $BR \[ $alldata2[0], \ $alldata2[1], \ $alldata2[2], \ $alldata2[3], \ $alldata2[4], \ $alldata2[5], \ $alldata2[6], \ $alldata2[7], \ $alldata2[8], \ $alldata2[9] \] \[ $alldata2[10], \ $alldata2[11], \ $alldata2[12], \ $alldata2[13], \ $alldata2[14], \ $alldata2[15], \ $alldata2[16], \ $alldata2[17], \ $alldata2[18], \ $alldata2[19] \] \[ $alldata2[20], \ $alldata2[21], \ $alldata2[22], \ $alldata2[23], \ $alldata2[24], \ $alldata2[25], \ $alldata2[26], \ $alldata2[27], \ $alldata2[28], \ $alldata2[29] \] \[ $alldata2[30], \ $alldata2[31], \ $alldata2[32], \ $alldata2[33], \ $alldata2[34] \] $BR Put a single stem in the center column labeled $BBOLD "stem." $EBOLD Put the leaves for data set 1 in the blanks on the left of the stem, and the leaves for data set 2 in the blanks on the right of the stem. You may need to scroll right to view the entire display. $BR$BR $BCENTER $table_start1 $table_row1[0] $table_end1 $table_start2 $table_row2[0] $table_row2[1] $table_row2[2] $table_row2[3] $table_row2[4] $table_row2[5] $table_row2[6] $table_row2[7] $table_row2[8] $table_end2 $ECENTER END_TEXT Context()->normalStrings; @rows=("","","","","","","","","","",8,@row8b,"","","","","","","","","","","","","","","","","",9,@row9b,"","","","","","","","","","","","",@row10,10,@row10b,"","","","","","","","","","","","","",11,@row11b,"","","",@row12,12,@row12b,"","","",@row13,13,@row13b,"","","","","","","","",@row14,14,"","","","","","","","","","","","","","",@row15,15,"","","","","","","","","",""); for ( $i = 0; $i<168; $i++ ) { if($rows[$i] eq "") { WEIGHTED_ANS( str_cmp($rows[$i]), 0 ); } else { WEIGHTED_ANS( str_cmp($rows[$i]), 1.2821 ); } } ENDDOCUMENT();