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 #include #include #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> number; { cout << "First Name: " << students[number].firstName << "Last Name: " << students[number].lastName << "Student ID: " << students[number].studentID << "Student E-mail: " << students[number].email << "Student GPA: " << students[number].gpa << endl; } } void studentsProc::displayStudent() { studentsProc::printList(); } void studentsProc::printList() const { cout << "Student List" << endl; for (int i = 0; i < size; i++) { cout << "Last Name: " << students[i].lastName << "First Name: " << students[i].firstName << "Student ID: " << students[i].studentID << "Student E-mail: " << students[i].email << "Student GPA: " << students[i].gpa << endl; } } void studentsProc::sortLastName() { for(int i=0; i0) { studentInfo temp = students[i]; students[i] = students[j]; students[j] = students[i]; } } } printList(); } void studentsProc::sortGpa() { for(int i=0; i> choice; cout << endl; switch (choice) { case 1: student1.retrieveStudent(); break; case 2: student1.insertStudent(); break; case 3: student1.deleteStudent(); break; case 4: student1.printStudent(); break; case 5: student1.displayStudent(); break; case 6: student1.sortLastName(); break; case 7: student1.sortGpa(); break; default: cout << "Please enter a value 1-7" << endl; } //end switch cout << endl; } while (choice != 7);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!