Java Reference
In-Depth Information
7.39 (Enhanced GradeBook ) Modify the GradeBook class of Fig. 7.18 so that the constructor ac-
cepts as parameters the number of students and the number of exams, then builds an appropriately
sized two-dimensional array, rather than receiving a preinitialized two-dimensional array as it does
now. Set each element of the new two-dimensional array to -1 to indicate that no grade has been
entered for that element. Add a setGrade method that sets one grade for a particular student on a
particular exam. Modify class GradeBookTest of Fig. 7.19 to input the number of students and
number of exams for the GradeBook and to allow the instructor to enter one grade at a time.
Making a Difference
7.40 (Polling) The Internet and the web are enabling more people to network, join a cause, voice
opinions, and so on. Recent presidential candidates have used the Internet intensively to get out
their messages and raise money for their campaigns. In this exercise, you'll write a simple polling
program that allows users to rate five social-consciousness issues from 1 (least important) to 10
(most important). Pick five causes that are important to you (e.g., political issues, global environ-
mental issues). Use a one-dimensional array topics (of type String ) to store the five causes. To sum-
marize the survey responses, use a 5-row, 10-column two-dimensional array responses (of type
int ), each row corresponding to an element in the topics array. When the program runs, it should
ask the user to rate each issue. Have your friends and family respond to the survey. Then have the
program display a summary of the results, including:
a)
A tabular report with the five topics down the left side and the 10 ratings across the top,
listing in each column the number of ratings received for each topic.
b)
To the right of each row, show the average of the ratings for that issue.
c)
Which issue received the highest point total? Display both the issue and the point total.
d)
Which issue received the lowest point total? Display both the issue and the point total.
Search WWH ::




Custom Search