Dynamic Linked Lists and File Manipulation
Through this assignment, you are going to be maintaining a file of all students and their registered courses to learn the concepts of structures, pointers to structures, dynamic memory allocation and file manipulation. For this, a structure called studentInfo with the following member elements should be defined:
- StudentID 9 char long
- First Name 20 char long
- Last Name 25 char long
- Number of Courses Attending integer
- Array of CourseInfo a 10 element array of courseInfo elements
- next Pointer to the next student structure in the list
where the CourseInfo structure has been defined as follow:
struct CourseInfo{ int courseID; char courseName[30];
};
Your task is to:
Write a complete, well documented C program that will be able to:
- Add a new student
- Delete a student and all information related to that student
- Search for a student and their information
- Display a list of current students
- Save student information to file
- Load student information from file
Assignment Description:
You are provided with a data file called studentList.txt that has the data for a number of students. You are required to read this data from the input file into a sorted linked list data structure. The linked list must be sorted based on the StudentID. The sample input file will end with a line that has three stars. An example of an input file with two fictional students is:
studentList.txt |
111111111LisaPorter3ENEE 114CMSC 412ENME 515333333333AlexSimpson1CMSC 412*** |
For each student, the data file is formatted line by line in the following manner: <student ID>
<first name>
<last name>
<number of courses they are taking>
<course name> <course id>
After loading the student list, your program should be able to interactively ask the user for input. Your interactive menu should have the following inputs:
- Add new student
- Delete a student
- Search for a student
- Display current students
- Save student information to file
- Exit
Hints:
- The following points are to be considered:
- Student ID should be unique and 9 characters of numbers (such as 123456789, 103449977)
- First name and Last Name should be started with capital letters (upper case).
- Student information should be sorted based on the student IDs both in the linked list and in the input/output file.
- Your program should implement at least the following functions:
- addStudent () : To add a new student and his/her registered courses.
- Make sure the first letter of the first and last names is upper case (capital letter).
- The student ID should be unique; you cannot have two students with the same StudentID. So, before adding a student, search for the studentID to be sure that you have not had it previously entered.
- If the linked list is empty, the new student is the head of the list. If not, search through the linked list to find the appropriate spot within the sorted linked list.
- deleteStudent(): To delete a student information using its StudentID.
- Search the linked list for a student matching the studentID passed in. If it is found, delete it from the linked list.
- Note that the linked list is sorted based on studentID!
- searchStudentID(): To search for a student using studentID
- You do not have to search all the linked list as it is sorted based on studendIDs. This function can be called from addStudent() and deleteStudent() functions.
- searchStudentlName(): To search for a student using his/her last name and display the related information if the student exists.
- You have to search all the linked list as it is not sorted based on last names
- Before starting the search, make sure the name supplied by the user has a capital letter for the first letter.
- displayStudentInfo(): To display the current student information that exists in the linked list
- saveStudentInfo(): To save student information from the sorted linked list to a file (inputStudents.txt)
- loadStudentinfo(): To read all the student information from an input file (studentList.txt)
- This function should be called at the beginning of you program to load all previous student information saved in the input file
- Student information should be formatted and stored in a sorted linked list.
- exit(): To save student information in a file (inputStudents.txt) and exit from the program
- addStudent () : To add a new student and his/her registered courses.
Sample Run
A sample run of the program, with its interactive menu is shown below.
- Add new student
- Delete a student
- Search for a student
- Display current students
- Save student information to file
- Exit
> 1
Adding new student:
Student ID : 222222222
First name : john
Last name : Rezaei
Number of courses: 2
Course ID: 412
Course Name: CMSC
Course ID: 123
Course Name: MATH
- Add new student
- Delete a student
- Search for a student
- Display current students
- Save student information to file
- Exit > 4 Student 1:
111111111
Lisa
Porter
3
ENEE 114
CMSC 412
ENME 515
Student 2:
222222222
John
Rezaei
2
CMSC 412
MATH 123
Student 3:
333333333
Alex
Simpson
1
CMSC 412
- Add new student
- Delete a student
- Search for a student
- Display current students
- Save student information to file
- Exit
> 3
What is the last name of student? porter
111111111
Lisa
Porter
3
ENEE 114
CMSC 412
ENME 515
- Add new student
- Delete a student
- Search for a student
- Display current students
- Save student information to file
- Exit
> 2
Student ID: 111111111 Student information deleted.
- Add new student
- Delete a student
- Search for a student
- Display current students
- Save student information to file
- Exit > 4 Student 1:
222222222
John
Rezaei
2
CMSC 412
MATH 123
Student 2:
333333333
Alex
Simpson
1
CMSC 412
- Add new student
- Delete a student
- Search for a student
- Display current students
- Save student information to file
- Exit
> 6
Save student information to file before leaving? y Student List saved successfully. Bye!
Reviews
There are no reviews yet.