Lab 11

4/27/09

Reading and Writing Files

In this lab we will create an array of records, write them to a file, read them back into another array, and print out the data from the file.


  1. Create a Person class that has the fields:
    firstName - string
    lastName - string
    age - integer 
    salary - double

  2. The Person class needs to be able to get and set each field.
  3. In main, create an array of Persons with three or four Persons added to it. Your program does not have to be interactive.
  4. Print out the array of Persons
  5. Your program should then open a file for writing, and put one person record on each line of the file.
  6. Close the disk file.
  7. Open the same file for reading
  8. Read each line of the file into a Person object and place the Person into an array
  9. Print out the array.

courses/cs203-200803/assignments/lab11.txt · Last modified: 2009/04/27 13:53 by jones
VCCS Top Events Extended Site Search Login Vassar Science Web Vassar Home Driven by DokuWiki Valid XHTML 1.0