This is a C++ Programming assignment. I really need help on this. The informatio
ID: 3742730 • Letter: T
Question
This is a C++ Programming assignment. I really need help on this. The information is : first name: Justin ; Last name: Askew ; Student ID: 0458103 ; Email: j.o.askew@spartans.nsu.edu ; GPA: 3.4 . Thank you so much!
CSC 372 Program Assignment 1: Due Date September 20h 11:59 PM Due Date: Tuesday, September 4th 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 1. Create a student class or struct based on the student structure 2. Create a students class which contains three private members-an array of students, the size of the array, and a function to print the contents of a process. The processes class will also provide the following functionality a. b. c. d. e. f. g. h. 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 1. 2. 3. Load the students file students.dat Create a menu to carry out the given operations Implement input validation to avoid erroneous program errorsExplanation / Answer
Answer:
#include <fstream>
#include<iostream>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
class student
{
private:
string FName,LName,Email;
float GPA;
unsigned int StudentID;
public:
void input(string fname, string lastname, string email, float gpa, unsigned int id);
string getFName();
string getLName();
string getEmail();
float getGPA();
int getStudentId();
};
void student::input(string firstname, string lastname, string email, float gpa, unsigned int id)
{
FName = firstname;
LName = lastname;
Email = email;
GPA = gpa;
StudentID = id;
}
string student::getFName(){
return FName;
}
string student::getLName(){
return LName;
}
string student::getEmail(){
return Email;
}
float student::getGPA(){
return GPA;
}
int student::getStudentId(){
return StudentID;
}
class students
{
private:
student std[10];
int n;
public:
void print();
void push(student s,int index);
void setCount(int count);
};
void students::push(student s,int index)
{
std[index]=s;
}
void students::setCount(int count)
{
n=count;
}
void students::print()
{
for(int i=0;i<=n;i++){
cout<<"Details of students";
cout<<"First Name : "<< std[i].getFName();
}
}
int main()
{
string firstname, lastname, email;
float gpa;
unsigned int studentId;
int count = 0;
student s1;
students students1;
cout<<"printing";
std::ifstream file("D:\Data\Students.dat");
std::string str;
while (std::getline(file, str))
{
vector <string> tokens;
stringstream check1(str);
string intermediate;
while(getline(check1, intermediate, ' '))
{
tokens.push_back(intermediate);
}
firstname = tokens[1];
lastname = tokens[2];
stringstream id(tokens[3]);
id >> studentId;
email = tokens[4];
stringstream gp(tokens[5]);
gp >> gpa;
s1.input(firstname,lastname,email,gpa,studentId);
students1.push(s1,count);
count++;
}
students1.setCount(count);
int process;
cout << "1 Insert a student into the student list ";
cout << "2 Print the contents for a list of students ";
cout << "3 Print the contents of a student record ";
cout << "4 Delete a student from the student list ";
cout << "5 Retrieve and print a student from the student list ";
cout << "6 Sort the student list by last Name ";
cout << "7 Sort the student list by GPA";
cin >> process;
switch (process)
{
case 1:
students.insertStudent(student s);
break;
case 2:
students.printListOfStudents();
break;
case 3:
students.printContentStudentRecord();
break;
case 4:
students.deleteStudent(student s);
break;
case 5:
students.printStudentList();
break;
case 6:
students.sortByLNamet();
break;
case 7:
students.sortByGPA();
break;
default:
cout << "Error! option is not correct";
break;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.