Java Reference
In-Depth Information
The number a is the average of the numbers n 1 , n 2 , n 3 , and so forth. Hint: Write
your program so that it first reads the entire file and computes the average of all the
numbers, then closes the file, and then reopens the file and computes the standard
deviation. You will find it helpful to first do Programming Project 10.8 and then
modify that program in order to obtain the program for this project.
11. Change the definition of the class Person in Display 5.19 to be serializable. Note
that this requires that you also change the class Date . Then write a program
to maintain a binary file of records of people (records of type Person ). Allow
commands to delete a record specified by the person's name, to add a record, to
retrieve and display a record, and to obtain all records of people within a specified
age range. To obtain the age of a person, you need the current date. Your pro-
gram will ask the user for the current date when the program begins. You can do
this with random access files, but do not use random access files for this exercise.
Use a file or files that record records with the method writeObject of the class
ObjectOutputStream .
12. Programming Projects 6.12 and 6.13 asked you to write a program to play a simple
trivia game consisting of five questions. The questions, answers, and point values
were hardcoded into array(s). This programming project involves moving the trivia
questions into one or more binary files instead, and then loading the trivia ques-
tions into memory when the program starts.
First, write a program that allows an administrator to manage the questions for the
trivia game. When the program is run, it should check to see if a data file exists. If
the data file exists, then the trivia questions should be loaded from the data file into
array(s) in memory. If the data file does not exist, start the program with no trivia
questions in memory. The program should then present a menu that allows the
administrator to list all trivia items (question, answer, and value) in the database,
add a new trivia item, or delete an existing trivia item. Upon exiting the program,
the trivia data in memory should be stored to one or more binary files using the
writeObject method.
Second, modify either solution to Programming Projects 6.12 or 6.13 to read
in the trivia data from the binary file created by the administrator's program.
Note that the game is no longer limited to five questions, since an arbitrary
number of trivia items may be created by the administrator's program and
stored in the binary file(s).
Search WWH ::




Custom Search