Question: Hi guys, We had a previous assignment to make a student record program and now we are supposed to convert it to use class and

Hi guys, We had a previous assignment to make a student record program and now we are supposed to convert it to use class and objects of OOP Here is the original program: I need help converting to class structure. I'm having trouble doing that with vectors. Any insight is very appreciated.

#include

#include

#include

using namespace std;

struct studentType

{

string studentFName;

string studentLName;

int testScore;

char grade;

};

// Function to read students'data **INPUT**

void readData(vector &students)

{

int n;

cout << "Enter the number of students: ";

cin >> n;

for (int i = 0; i < n; i++)

{

studentType student;

cout << "Enter student " << i + 1 << " first name: ";

cin >> student.studentFName;

cout << "Enter student " << i + 1 << " last name: ";

cin >> student.studentLName;

cout << "Enter student " << i + 1 << " test score: ";

cin >> student.testScore;

students.push_back(student);

}

}

// Function to assign grades **PROCESS**

void assignGrades(vector &students)

{

for (int i = 0; i < students.size(); i++)

{

if (students[i].testScore >= 90)

{

students[i].grade = 'A';

}

else if (students[i].testScore >= 80)

{

students[i].grade = 'B';

}

else if (students[i].testScore >= 70)

{

students[i].grade = 'C';

}

else if (students[i].testScore >= 60)

{

students[i].grade = 'D';

}

else

{

students[i].grade = 'F';

}

}

}

// Function to find the highest test score **PROCESS**

int findHighestScore(const vector &students)

{

int highestScore = 0;

for (int i = 0; i < students.size(); i++)

{

if (students[i].testScore > highestScore)

{

highestScore = students[i].testScore;

}

}

return highestScore;

}

// Function to print students with highest score **OUTPUT**

void printStudentsWithHighestScore(const vector &students, int highestScore)

{

cout << endl << "Student(s) with the highest score of " << highestScore << ":" << endl << endl;

for (int i = 0; i < students.size(); i++)

{

if (students[i].testScore == highestScore)

{

cout << students[i].studentLName << ", " << students[i].studentFName << endl << endl << "Letter Grade: " << students[i].grade << endl << endl;

}

}

}

int main()

{

vector students;

readData(students);

assignGrades(students);

int highestScore = findHighestScore(students);

printStudentsWithHighestScore(students, highestScore);

return 0;

}

//Chelsea Bonyata

//Feb 14 2023

//Program that stores user input into a structure and performs and displays calculations on data provided

#include

#include

#include

using namespace std;

struct studentType

{

string studentFName;

string studentLName;

int testScore;

char grade;

};

// Function to read students'data **INPUT**

void readData(vector &students)

{

int n;

cout << "Enter the number of students: ";

cin >> n;

for (int i = 0; i < n; i++)

{

studentType student;

cout << "Enter student " << i + 1 << " first name: ";

cin >> student.studentFName;

cout << "Enter student " << i + 1 << " last name: ";

cin >> student.studentLName;

cout << "Enter student " << i + 1 << " test score: ";

cin >> student.testScore;

students.push_back(student);

}

}

// Function to assign grades **PROCESS**

void assignGrades(vector &students)

{

for (int i = 0; i < students.size(); i++)

{

if (students[i].testScore >= 90)

{

students[i].grade = 'A';

}

else if (students[i].testScore >= 80)

{

students[i].grade = 'B';

}

else if (students[i].testScore >= 70)

{

students[i].grade = 'C';

}

else if (students[i].testScore >= 60)

{

students[i].grade = 'D';

}

else

{

students[i].grade = 'F';

}

}

}

// Function to find the highest test score **PROCESS**

int findHighestScore(const vector &students)

{

int highestScore = 0;

for (int i = 0; i < students.size(); i++)

{

if (students[i].testScore > highestScore)

{

highestScore = students[i].testScore;

}

}

return highestScore;

}

// Function to print students with highest score **OUTPUT**

void printStudentsWithHighestScore(const vector &students, int highestScore)

{

cout << endl << "Student(s) with the highest score of " << highestScore << ":" << endl << endl;

for (int i = 0; i < students.size(); i++)

{

if (students[i].testScore == highestScore)

{

cout << students[i].studentLName << ", " << students[i].studentFName << endl << endl << "Letter Grade: " << students[i].grade << endl << endl;

}

}

}

int main()

{

vector students;

readData(students);

assignGrades(students);

int highestScore = findHighestScore(students);

printStudentsWithHighestScore(students, highestScore);

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!