Record of Array of Records - A List of Records
Record of Array of Records - A List of Records
Overiew: Example Records and Arrays and Lists of Records
- These notes cover the following:
- An example that uses:
- A record type
- An array of these records
- A list of these records
- We will see what a list means in this context
Sample Problem
- Read in an employee record file
- Read an employee record file into an array
- Use an array to create a list of employee information
Sample Program 1: Employee Information
- Sample program: read in all data and print who has salary over $50,000
- Simply read and print the data, all in one procedure
- Now, let's do it again, with a new record type:
- Design the type
- What procedures should we have?
Example - Version 2: File of Employee Information
- Problem: Let's work with a a file of employee data
- File emp2.dat contains employee information:
- Two lines per employee:
- Line 1: Name and 6 digit ID
- Line 2: Salary: float
Example: File of Employee Information
- Problem: Let's work with a a file of employee data
- File employees.dat contains employee information:
- First line is header
- Remaining lines:
- Name: 20 Characters
- ID number: 6 characters
- Salary: float
- Fixed length name and ID
Sample Program 2: More Employee Information
- Now, let's print all the data, in reverse order
- What data structure do we need
- What problem do we encounter
- What is a simple solution?
- What is a better solution?
Sample Program 3: Procedures
- Let's create a version with procedures
Sample Program 4: A List of Employees
- How can we make each procedure have exactly one parameter?
- Answer: group the ?? and the ?? into a ??.