Question: CSC 372 Program Assignment 2: Due Date October 16 th 1:29 PM Program Summar y Write a C++ object-oriented program to manage a file system
CSC 372 Program Assignment 2: Due Date October 16th 1:29 PM
Program Summary
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
If you had a working program 1, then there is no need to change your main function. If you do not have a satisfactory working program, I can provide you with one.
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
How to change this code to use pointers and linked list?
#include
using namespace std;
struct studentInfo { string firstName; string lastName; unsigned int studentID; string email; float gpa; }; class studentsProc { public: void studentList(); void loadList(); void retrieveStudent(); void insertStudent(); void deleteStudent(); void printStudent(); void displayStudent(); void sortLastName(); void sortGpa(); studentsProc();
private: studentInfo students[40]; int size; void printList() const; }; studentsProc::studentsProc() { size = 0; } void studentsProc::studentList() { cout << "0. Smith, Jefferey" << endl; cout << "1. Lee, Jackson" << endl; cout << "2. Gonzales, Mariana" << endl; cout << "3. Jones, Mike" << endl; cout << "4. Wiliams, Anita" << endl; cout << "5. Ronsinson, Taylor" << endl; cout << "6. Clark, Allen" << endl; cout << "7. Turner, Tavon" << endl; cout << "8. Jenkins, Nelson" << endl << endl; } void studentsProc::loadList() { ifstream infile; infile.open("students.dat"); size = 0; while (!infile.eof()) { infile >> students[size].lastName; infile >> students[size].firstName; infile >> students[size].studentID; infile >> students[size].email; infile >> students[size].gpa; size++; } infile.close(); } void studentsProc::retrieveStudent() { int number; studentsProc::studentList(); cout << "Please Enter the Position of the Student you Wish to Retrieve " << endl; cin >> number; { cout << "Student Name: " << students[number].firstName << " " << students[number].lastName << endl; } } void studentsProc::insertStudent() { int position; cout << "Enter the Position of the New Student you Would Like to Add: " << endl; cin >> position; cout << endl; cout << "Enter the Following Information About The Student: " << endl; cout << "First Name: "; cin >> students[position].firstName; cout << "Last Name: "; cin >> students[position].lastName; cout << "Student ID: "; cin >> students[position].studentID; cout << "E-Mail: "; cin >> students[position].email; cout << "GPA: "; cin >> students[position].gpa; cout << "The New List Is: " << endl; studentsProc::displayStudent(); } void studentsProc::deleteStudent() { int position; cout << "Enter the Position of the Student you Would Like to Delete: " << endl; cin >> position; for(int i=position;i
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
