Docsity

Programming Assignment 1: Student Object and File I/O - Prof. Douglas Heisterkamp, Assignments of Computer Science

Partial preview of the text

Download Programming Assignment 1: Student Object and File I/O - Prof. Douglas Heisterkamp and more Assignments Computer Science in PDF only on Docsity!

Programming Assignment 1

Due: September 17

  • Programming project #1, page 12.
  • Programming project #22, page 152.

Note: for testing purposes, you will need to implement project 14 on page 42 (stream I/O for the object), but that part will not be graded.

PA1, part 1 — design a student object

  • Data members should include: identifier, name, address, date of first enrollment, number of credit hours com- pleted.
  • Methods should include: initialization, assignment, mod- ifying field values such as incrementing the number of credit hours.
  • Test data will be provided as an ASCII file with one field per line, in the following order: identification, name, ad- dress, date, credit hours. Student will follow student with no gaps until the end of file.
  • The program should be named PA1. The usage for PA1 is PA1 -{d|l|f} [filename] The ’-’ option is required and specifies the buffer type, -d is delimited, -l is length, and -f is fixed. The filename is optional and is the name of the output file. If not given, then use standard output. PA1 should initialize the stu- dents by reading from standard input. Example usages: PA1 -d srecords < testdata which creates file srecords as a file of variable length records using field delimiters.

Using a Length indicated record

  • Length indicator at the beginning of each record ⇒ know the sum of field lengths before writing record to file... need a buffer.
  • buffer — simply a character array: a location to place fields and delimiters as the information for the record is generated.
  • Length may be stored as binary or as text.