Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Student Roster using Linked List For this assignment, you are tasked with implementing a student roster using a sorted linked list. Each student should include

Student Roster using Linked List
For this assignment, you are tasked with implementing a student roster using a sorted linked list. Each student should include the student's name, SSN, and grade. The linked list data structure will be utilized to store all student records.
The test program is expected to read data from an input file and then insert each student record into the sorted list based on SSN. Additionally, students should attempt to delete specific students from the list. After each insert or delete operation, it is required to print the entire student list.
//StudentLinkedList.h
struct StudentData {
string name;
int ssn;
char grade;
};
struct StudentNode {
StudentData student;
StudentNode* next;
};
class StudentLinkedList
{
public:
StudentLinkedList();
void addStudent(StudentData student);
void deleteStudent(int);
void printList(ostream&);
private:
StudentNode* head;
};
StudentLinkedList::StudentLinkedList()
{
head = NULL;
}
Implement all methods except default constructor.
//Driver.cpp
Underlined provides an explanation of the methods:
(7 pts) addStudent: read each student from file, insert into linked list.
(6 pts) PrintList: Print all students on the screen.
(7 pts) deleteStudent: Delete a student based on the given Social Security Number (SSN).
#include StudentLinkedList.h
int main()
{
StudentLinkedList slist;
StudentData student;
//Read each student from the file and insert into linked list using while loop
slist.printList(cout);
cout <<"-----------------------------------------------------"<< endl;
//Deleting one student from the student linked list!!!
cout <<Enter SSN to be deleted: ;
int sno;
cin >> sno;
slist.deleteStudent(sno);
slist.printList(cout);
return 0;
}
//students.txt: Download this file from Canvas.
Betsy 123456789 A
Sam Spade 234565677 B
Annie Smith 324233456 A
Thomas J. Jones 345344344 A
Allan Adaire 324234234 C
Jennifer Smallville 234234333 A
Note: Each value (name, ssn, and grade) is separated by tab key (\t). Sample output:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions