Output
The input data as they are read.
A report consisting of the title that was read from the data, the number of
scores, the mean, the standard deviation (all clearly labeled), and the
histogram.
5.Write an application that, within an event loop, reads an apartment number
and the number of occupants in the apartment. The apartment number serves
as an index into an array of apartments. The components in the array
represent the number of people who live in the apartment. Use the data struc-
ture described in this chapter. Use window input, and when the user presses
the Quit button print the number of people in the building, the average number
of people per apartment, the number of apartments with above-average occu-
pancy, and the number with below-average occupancy.
Case Study Follow-Up
1.The exam-grading application contains no error checking.
a.What happens if a letter other than a T or F is entered in the key?
b.What happens if a letter other than a T or F is entered for a student?
c. It is easy to include a check that each input value is a T or F, but what should
the application do if an error occurs?
2.Redesign and rewrite the exam-grading application to incorporate error check-
ing based on the answers in Exercise 1. Use an exception class.
3.Using the solution of reading the sequence of T’s and F’s as a string means that
the user doesn’t really have to enter the number of questions. Why? Because
the array created from the string also has a lengthfield. Rewrite this
application so as to take advantage of this information.
521