{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Thorndale};}{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}
{\f28\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}{\f29\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f31\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}
{\f32\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}{\f33\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f34\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}
{\f35\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}{\f44\fmodern\fcharset238\fprq1 Courier New CE;}{\f45\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f47\fmodern\fcharset161\fprq1 Courier New Greek;}
{\f48\fmodern\fcharset162\fprq1 Courier New Tur;}{\f49\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f50\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f51\fmodern\fcharset186\fprq1 Courier New Baltic;}}{\colortbl;\red0\green0\blue0;
\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;
\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \snext0 Normal;}{
\s1\ql \li0\ri0\sb240\sa60\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\fs28\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext15 heading 1;}{\s2\ql \li0\ri0\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\b\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon0 \snext0 heading 2;}{\s3\ql \li0\ri0\keepn\nowidctlpar\faauto\rin0\lin0\itap0 \b\fs20\ul\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon0 \snext0 heading 3;}{\*\cs10 
\additive Default Paragraph Font;}{\s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext15 Default;}{\s16\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Text body;}{\s17\ql \fi-283\li567\ri0\sa120\nowidctlpar\tx567\aspalpha\faauto\rin0\lin567\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon16 \snext17 
Hanging indent;}{\s18\ql \li0\ri0\sb240\sa120\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs28\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Heading;}{\s19\ql \fi-360\li360\ri0\nowidctlpar\aspalpha\faauto\rin0\lin360\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext19 List;}{\s20\ql \fi-360\li720\ri0\nowidctlpar\aspalpha\faauto\rin0\lin720\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext20 List 2;}{
\s21\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext21 header;}{\s22\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon16 \snext22 Table Contents;}{\s23\qc \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\i\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon22 \snext23 
Table Heading;}{\s24\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext24 Index;}{\s25\qc \li0\ri0\sb240\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\b\fs32\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext26 Title;}{\s26\qc \li0\ri0\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Subtitle;}{
\s27\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext27 footer;}{\s28\ql \li0\ri0\sb120\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\i\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext28 caption;}{\*\cs29 \additive \cf1\lang0\langfe255\langfenp255 Numbering Symbols;}{\*\cs30 \additive \cf1\lang0\langfe255\langfenp255 WW-Default Paragraph Font;}{\*\cs31 
\additive \cf1\lang0\langfe255\langfenp255 \sbasedon30 page number;}}{\info{\author CNRS}{\operator CNRS}{\creatim\yr2003\mo8\dy29\hr23\min17}{\revtim\yr2003\mo10\dy24\min47}{\printim\yr2003\mo10\dy10\hr9\min12}{\version7}{\edmins9}{\nofpages3}
{\nofwords1272}{\nofchars7252}{\*\company CNRS-HSU}{\nofcharsws8905}{\vern8269}}\margl1440\margr1440\margt1400\margb720 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120
\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\nolnhtadjtbl \fet0\sectd \sbknone\linex0\headery709\sectdefaultcl {\header \pard\plain \s21\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\fs16 CS 131 - Homework #8\tab \tab p. }{\field{\*\fldinst {\fs16 \\page}}{\fldrslt {\fs16\lang1024\langfe1024\noproof 3}}}{
\par }{\fs16 Fall 2003
\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}
{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8
\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s15\qc \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b CS 131 - Intro to Computer Science I - Fall 2003
\par LAB #8 EXERCISE and Homework #8
\par 
\par lab #8 exercise due: Friday, October 24th, END of lab
\par HW #8 due: Friday, October 31st, }{\b\ul beginning}{\b  of lab
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b 
\par }\pard\plain \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {
You are to work individually on this assignment, and you will turn in the specified files by e-mail (one file per e-mail message, with the contents included in the text and not as an attachment, and with a copy CC'd to yourself as your receipt) as you hav
e been doing since CS 131 HW #6.
\par }\pard\plain \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b 
\par }\pard\plain \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {\b NOTE #1:}{
 you are always welcome to write additional auxiliary functions for homework problems --- do be sure to e-mail me such functions if you do so, however! Just also let me know which problem(s) they are for.
\par }\pard\plain \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b 
\par NOTE #2}{: the array-related examples from Wednesday 10-22-03's lecture, sumArray.cpp, tryMe1.cpp, and tryMe2.cpp, are now all available from the course web page, under "In-class examples". However, see Note #3 --- sumArray.cpp has been }{\b changed}{
 to reflect this.}{\b 
\par 
\par NOTE #3}{: By default, an array is passed differently than a single value, such as a float, bool, int, double, char, etc. It is }{\b not}{
 passed-by-value, and an array parameter's corresponding argument can be changed by the function, when declared in the "normal" way. If a function is not intended to change an array parameter, then }{\b const}{
 should be placed at the beginning of that array parameter's declaration. That is, for good style, the header for function }{\b sumArray}{ should be:}{\b 
\par 
\par }{\b\loch\af2 \tab \hich\af0\dbch\af0\loch\f2 double sumArray (const double numArray[\hich\af0\dbch\af0\loch\f2 ], int size)
\par 
\par }\pard\plain \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {So, the posted version of }{\b sumArray}{ has had this change made to it. }{\b 
Using const in the declaration of an array parameter that is intended to NOT be changed by a function is now a class style standard.
\par }\pard\plain \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b 
\par }\pard\plain \s3\ql \li0\ri0\keepn\nowidctlpar\faauto\outlinelevel2\rin0\lin0\itap0 \b\fs20\ul\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {LAB #8 EXERCISE
\par }\pard\plain \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {Consider a set of grades,
 expressed as double values. You'd like to be able to conveniently compute how many of those grades are passing grades (which we'll define to be any grade 73 or higher).
\par }\pard\plain \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b\loch\af2 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 1.\tab }{Write function}{\b  countPassing }{(in file}{\b  countPassing.cpp}{) which takes an array of dou
ble values and its size as arguments. It then returns how many of those grades are passing grades; it should not change the passed array.
\par }{\b 
\par 2.\tab }{Then write a main function that tests }{\b countPassing}{, in file }{\b test_countPassing.cpp}{.
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {*\tab First give it a "hard-coded" 
array of at least 10 grades, at least 3 of which are less than 73 and at least 1 of which is exactly 73. Call your function using this array, and compare the result to your expected result --- then print a message to the screen saying if this test passed 
or not.
\par 
\par *\tab Then allow the user to test it more dynamically. Ask the user how many grades he/she would like to enter, and then prompt them for that many grades. When done, call countPassing for the r
esulting array, and print to the screen a message saying how many of those grades were passing grades.
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {Demonstrate both of these before lab is over, and if they work and meet the above criteria, you will receive full credit for the lab exercise.
\par }{\b\loch\af2 
\par }{\b\ul HOMEWORK #8:
\par 
\par }\pard \s15\ql \fi-435\li435\ri0\nowidctlpar\aspalpha\faauto\rin0\lin435\itap0 {\b 1.\tab }{E-mail to me the following three files from your lab exercise:}{\b  countPassing.h}{, }{\b  countPassing.cpp}{, and }{\b test_countPassing.cpp}{.}{\b 
\par 
\par 2.\tab }{Let's say someone was curious about just how "random" }{\b randgen.cpp}{ is (the random number generating class from Owen Astrachan's }{\b  }{"A Computer Science Tapestry", 2nd Edition, MacGraw Hill) when used with our }{\b Dice}{
 class. Note that an array could be used to help in a small experiment looking into this.}{\b 
\par 
\par \tab }{Let's say that you rolled a 6-sided die 1000 times, and counted how many 
times you rolled a 1, how many times you rolled a 2, ... how many times you rolled a 6. Wouldn't an array be a convenient way to store those different number-of-rolls-per-dice-value?
\par }{\b 
\par \tab }{Write a main function in file}{\b  rollExp.cpp }{that performs the above experiment, using such an array and  our }{\b Dice}{ class appropriately. Hint: you should not need any }{\b if}{
-statements, nor should there be any sets of very-repetitive individual statements... (For this program, you should be able to use either the class-provided }{\b Dice}{ class or your }{\b Dice}{ class from HW #7.)
\par }{\b 
\par \tab }{What if I then asked you to perform the same experiment 10,000 times? or with an 8-sided die? How easy would }{\b rollExp.cpp}{ be to change? (If you've followed course coding standards --- very easy indeed...!) Try it, and
 see. (No, I won't be able to tell if you've actually tried to make these 2 changes  --- however, I will be looking to see if you've appropriately used the feature that would allow these }{\b 2}{ changes to be made with just }{\b 2}{ simple edits to }{\b 
rollExp.cpp}{. This gives you a chance to test and see if you have really done so, before I look at your resulting code...)
\par }{\b 
\par \tab }{When you are happy with your }{\b rollExp.cpp}{, change it back to roll a 6-sided die 1000 times, and e-mail me your file }{\b rollExp.cpp}{. (You do not need to send me any }{\b Dice}{ or }{\b randgen}{ related files --- I have those already.)

\par }{\b 
\par 3.\tab }{Consider a program that would allow a user to enter a collection of grades, and then permit the user to specify what information they would like about those grades. Assume that the grades are }{\b double}{ values.}{\b 
\par 
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab Write a function }{\b avgGrade}{ (with source code in file }{\b avgGrade.cpp}{) that takes two arguments, an array of }{\b double}{
 and a size, and it returns the average (as a double) of the first }{\b size}{ grades in the passed array. It should }{\b not}{ change its array argument. It should be quite easy to then use }{\b test_countPassing.cpp}{ to help to create }{\b 
test_avgGrade.cpp}{, that tests }{\b avgGrade}{ analogously.
\par }{\b 
\par }{\tab (note: }{\b avgGrade}{ should return }{\b 0}{ if some joker decides to call it with a size that is 0 or negative...)}{\b 
\par 
\par }{*\tab Also write two functions,}{\b  maxGrade }{and}{\b  minGrade }{(with source code in files}{\b  maxGrade.cpp }{and}{\b  minGrade.cpp}{, respectively), that each, also, take an array of }{\b double}{
 and a size, and return the largest and smallest array element, respectively, amongst the first }{\b size}{ elements within the passed arrays. Neither of these should change their array arguments, either. And, you should write }{\b test_maxGrade.cpp}{
 and }{\b test_minGrade.cpp}{, also analogous to }{\b test_countPassing.cpp}{, to help test }{\b maxGrade}{ and }{\b minGrade}{ analogously.
\par }{\b 
\par }{\tab (note: }{\b minGrade}{ and }{\b maxGrade}{ should both return }{\b 0}{ if some joker decides to call either with a size that is 0 or negative...)}{\b 
\par 
\par }{*\tab (and remember, you already have function }{\b countPassing}{ from problem #1...)
\par }{\b 
\par }{*\tab Finally, write a main function in file }{\b crunchGrades.cpp}{
 that asks the user how many grades he/she would like to enter, and then prompts them for that many grades. It then asks the user which of the following actions they would like to perform on the entered grades, printing out the following menu of options:

\par }{\b 
\par \tab }{\f2 What do you want done with these grades? }{
\par }{\f2     -------------------------------------------}{
\par }{\loch\af2 \tab \hich\af0\dbch\af0\loch\f2 Enter:\tab To see:
\par \tab \hich\af0\dbch\af0\loch\f2 ------\tab -------
\par }{\f2 \tab  1\tab \tab the average of these grades}{
\par }{\loch\af2 \tab \hich\af0\dbch\af0\loch\f2  2\tab \tab how many grades are passing grades
\par \tab \hich\af0\dbch\af0\loch\f2  3\tab \tab the highest grade
\par \tab \hich\af0\dbch\af0\loch\f2  4\tab \tab the lowest grade
\par 
\par \tab \hich\af0\dbch\af0\loch\f2  q\tab \tab to q\hich\af0\dbch\af0\loch\f2 uit the program
\par 
\par \tab \hich\af0\dbch\af0\loch\f2 Your choice: 
\par }{\b\loch\af2 
\par \tab }{It should return the results of the action they request, printing an appropriate message to the screen with that result, and then ask them what action they would like next. (I'll leave it as your choice whether to print th
e entire menu each time.) Keep asking, and giving the requested result, until the user enters q to quit.}{\loch\af2 
\par }{\b 
\par \tab }{You should use an appropriate array in this main function, of course, and make appropriate calls of all of the functions mentioned.
\par }{\b 
\par }\pard \s15\ql \fi-435\li435\ri0\nowidctlpar\aspalpha\faauto\rin0\lin435\itap0 {\b \tab }{When you are happy with all of your code for this problem, then e-mail me your resulting}{\b  avgGrade.cpp}{, }{\b 
test_avgGrade.cpp, minGrade.cpp, test_minGrade.cpp, maxGrade.cpp, test_maxGrade.cpp}{, and }{\b crunchGrades.cpp}{.}{\b 
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {\b 
\par }\pard \s15\ql \fi-435\li435\ri0\nowidctlpar\aspalpha\faauto\rin0\lin435\itap0 {\b 4.\tab }{Now consider a set of 5 Dice instances.  Write a program (whose main function is in file }{\b simpleRollSet.cpp}{
) that will use an array to hold a set of 5 Dice instances. It should roll those 5 dice once, and show the user what the resulting rolls were. It shou
ld then allow the user to re-roll those 5 dice as many times as he/she desires, by asking the user if he/she would like to roll again, and rolling the dice again and showing the results if he/she says yes, and ending the program when they answer no.  Anot
her requirement: do not recreate the 5 dice for subsequent rolls, if requested --- simply re-roll the dice that you rolled the first time. }{\b 
\par 
\par \tab }{(For this program, also, you should be able to use either the class-provided }{\b Dice}{ class or your }{\b Dice}{ class from HW #7.)
\par }{\b 
\par \tab }{E-mail to me your resulting}{\b  simpleRollSet.cpp}{.}{\b 
\par \tab 
\par }\pard \s15\ql \fi-15\li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\tab Throughout the homework, IF you create any additional helper functions, be sure to e-mail them to me along with your other homework files.
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {
\par }\pard \s15\ql \li-15\ri0\nowidctlpar\aspalpha\faauto\rin0\lin-15\itap0 {Remember --- when you are done with this homework, you should have sent me at least  12 e-mail messages, one each for }{\b countPassing.h}{, }{\b countPassing.cpp}{,  }{\b 
test_countPassing.cpp, rollExp.cpp,  avgGrade.cpp, test_avgGrade.cpp,  minGrade.cpp,  test_minGrade.cpp, maxGrade.cpp, test_maxGrade.cpp, crunchGrades.cpp,and simpleRollSet.cpp. }{
\par 
\par 
\par }{\b 
\par }{
\par }\pard \s15\qc \fi-435\li435\ri0\nowidctlpar\aspalpha\faauto\rin0\lin435\itap0 {\b 
\par }}