Question: Program Summar y MUST USE POINTERS AND LINKED LISTS!!!! Write a C++ object-oriented program to manage a file system for students at Norfolk State University:
Program Summary MUST USE POINTERS AND LINKED LISTS!!!!
Write a C++ object-oriented program to manage a file system for students at Norfolk State University:
First Name string
Last Name string
Student ID unsigned integer
Email string
GPA - float
The program will manipulate the student list based on students from the file students.dat
Class requirements
Create a student class or struct based on the student structure
Create a students class which contains two private members a pointer to a list of students and a function to print a students record. The students class will also provide the following functionality.
Load data from a data file into a student list
Retrieve and print a student from the student list
Insert a student into the student list
Delete a student from the student list
Print the contents of a student record
Print the contents for a list of students
Sort the student list by last Name
Sort the student list by GPA
Processing requirements
Load the students file students.dat
Create a menu to carry out the given operations
Implement input validation to avoid erroneous program errors
Structure of the file
students.dat First Name, Last Name, Student ID, Email, GPA
Smith Jefferey 891789 j.smith@spartans.nsu.edu 3.75 Lee Jackson 3678902 j.lee@spartans.nsu.edu 3.66 Gonzales Mariana, 168790 m.gonzales18@spartans.nsu.edu 4.0 Jones Mike 8973125 m.jones143@spartans.nsu.edu 3.1 Williams Anita 2985465 a.williams@spartans.nsu.edu 3.64 Ronsinson Taylor 3278976 t.robinson@spartans.nsu.edu 3.55 Clark Allen 1094567 a.clark@spartans.nsu.edu 3.48 Turner Tavon 318796 t.turner@spartans.nsu.edu 3.2 Jenkins Nelson 289563 n.jenkins@spartans.nsu.edu 3.0
Code I have so far:
using namespace std;
#include
#include
#include
struct student;
typedef student * studentptr;
struct studentType
{
int info;
studentType *link;
};
studentType *head, *tail;
struct student
{
string firstName;
string lastName;
unsigned int studentID;
string email;
float gpa;
studentptr next;
};
class studentsProc // Definition of class named studentsProc
{
public:
void loadList(studentptr & students); // Function that loads data from a data file into a student list
private:
student * students; // Pointer to the list of students
void printList() const; //Print the contents of the list
};
void loadList(studentptr & students)
{
ifstream infile;
infile.open("students.dat");
students = NULL; //head pointer points no where
student temp;
studentptr temp_ptr;
while (!infile.eof())
{
temp_ptr = new student;
infile >> temp_ptr->firstName >> temp_ptr->lastName >> temp_ptr->studentID >> temp_ptr->email >> temp_ptr->gpa;//place data in the node
temp_ptr->next = students;
students = temp_ptr;
}
infile.close();
}
int main()
{
studentsProc student1;
studentptr students;
loadList(students);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
