CS210 Data Structures & Algorithms I

LAB 3

w/b 8/11/99

Mr. Tom Lysaght

Assignment due Friday, November 19th

 

 

Login at a PC using login PC1 and NO password (just press RETURN).

 

 

Using functional decomposition design a program which stores student data as an array of records. The following details are input for each student: FirstName, LastName, StudentNumber and average grade (GradePointAvg).

The program should allow the user to add a new record, print a record and find a record based on FirstName.

 

Write code for the above program using a struct as a data structure for each student's data i.e.,

Struct Student

{

string FirstName;

string LastName;

int StudentNum;

double GradePointAvg;

}

Declare an array of struct:

Student StudentData[MAX_SIZE];

  1. Initialise each struct entry in the array to some value (e.g., empty string " " for FirstName and LastName). Use a constant as the array size.
  2. Ask the user to input student data and store this in a struct at each array position.
  3. Write a function which prints out the details in the array:
  4. Void PrintRecord(Student s);

    and a function to print out all student details in the array:

    Void PrintData(Student SData[ ], int numEntries);

  5. Write a function Initialise(Student &s) which initialises a struct and use this to initialise each entry in the array.
  6. Write a function ReadData(Student &s) which reads data into a struct and a function to place the data into the array AddRecord(Student SData[], int &numEntries). The function AddRecord( ) can call the function ReadData( ).
  7. Write a function to find a particular entry by comparing the FirstName with a name input by the user.

Use a counter numEntries to hold the number of records input to the array. Use the array name in the call to a function e.g.,

AddRecord(StudentData,numEntries).

 

 

 

Save your work on a floppy disk. Also hand up a printout of the refinement and code.

The refinement may be handwritten.