CSC 372
Laboratory:  Building a List

File needed: lab2.txt

The file contains several student records consisting of (one field per line) a last name, a first name, the student number, and a letter grade.

Consider the structs:

struct Student
char last[20];
char first[20];
long number;
char grade;
};
struct Node {
Student student;
Node * next;
};

Write a program that will have the following characteristics:

An "add_student" function that will add a student in alphabetical order according to last name.
A "load_list" function that will open the function for reading; read in each student, and place the student into the list using the add_student function.
A "display_list" function to carefully display each student - one student per line.
A "get_student" function that will prompt the user for student information then add the student to the list using the add_student function.
A "load_file" function that will open the file lab2.txt for writing and place all the students in the linked list into the file.
An "average" function that calculates the floating point numeric average of all students in the list, where A is a 4, B is a 3, etc.
A "menu" function that will allow the user to choose among placing a new student in the list, displaying the list, finding and printing the average, or exiting the program.

The programs flow should be

1 Load the names from the file into the list.

2 Handle the menu choices

3 Before exiting, place the names in the list back into the file.

You must include all of your necessary files on the diskette. Your program's name must be lab2.cpp.


© Computer Science Department NSU.
Permission granted for non-commercial use only.