Skip to content

CS 1415 - Lab #7

Objective: 

Program with a Database File

Preparation: 

Review Chapter 12 from Starting Out with C++ by Gaddis

Programming: 

  1. You will place all your code in one file.  Name the file LlllFfffLab07.cpp where Llll is the first four letters of your last name and Ffff is the first four letters of your first name.
  2. Write a database program that deals with a database file of student records. The database file will be a random-access file of binary data. Each student record should consist of last name, first name, age, and gpa fields in that order. The last name and first name will be c-strings (character arrays) of 20 and 15 characters respectively. The age will be an int and the gpa will be a double. Use a structure to represent the record. The program should allow the user to specify the name of the database file. It should open the file for both input and output. The program should not read all data into memory, instead it should interact with the file dealing with one record at a time as necessary. The file may or may not exist initially. If it does not initially exist, it will need to be created.
  3. The program should be menu-driven with the following options:
      1. Display Summary List of Entries
      2. Display an Entry 
      3. Add an Entry 
      4. Edit an Entry
      5. Quit. 
  4. The Summary List of Entries option should read all records one at a time displaying on the monitor a numbered list of last names. The Display an Entry option should display the complete record of a given entry based on the number of the entry. The Add an Entry option will add a new entry to the end of the file. The Edit an Entry should allow the user to change any/all fields of a chosen record. Each option should interact with the file reading the data as necessary and writing any data as necessary for that option. (We will not deal with deleting an entry.)
  5. Verify your program works correctly.
  6. Submit your source code file to ude.wons@nosneros.htrag. Due at 8:00 am on 18 February.