Comp 110L
Lab Project #9
Due: 11/2/2009
- Write a program that reads in a
set of test scores, computes their average, and finds out how many scores
are above the average. Use a
sentinel value of -1 to indicate the end of the set of scores. Assume that the number of test scores is
less or equal to 30. Your solution
should include two methods in addition to the main method. One to compute the average and one to
print all scores above the average.
(This is an expanded version of problem 6.1 on page 222 of the
book.)
- Write a program that generates n random integers
between 0 and 9 (where n
is a read in value) and displays the count for each integer. (Hint:
Use (int)(Math.random()
* 10)
to generate a random integer between 0 and 9.
Use an array of ten integers, say counts, to store the counts for the
number of 0’s, 1’s, . . . , 9’s. This is a
slightly modified version of problem 6.7 on page 222 of the book.)
For each of the above problems be sure to do
the following:
1.
Plan
your solution by writing down the algorithm to solve the problem before you write the code. Express the algorithm design in one of the
following three forms:
·
A
flow chart
·
A
block diagram
·
Pseudo
Code
2.
Make
sure your programs are self-documenting including an appropriate comment header
block.
3.
Test
the programs by running at least three test cases on each.