I this lab assignment, use class to create the data structure of student records
ID: 3677059 • Letter: I
Question
I this lab assignment, use class to create the data structure of student records. Each record contain RUID, student name, quiz grades, and exam grades. The data structure should be declared as below. All member data of the class are declared as private data. class students public: IW all necessary member functions here; W using the friend function in class friend void change_name)passing necessary inputs private struct record ( int RUID; string first name; string last name; vector edouble> quiz grades array exam grafes; vector crecord student records; In this assignment, we also introduce the friend function of the class. A function can be declared as friend of the class as seen as above. A friend function is not a member function of the class. However, it has access to the private data of the class. To call the friend function in the main0 function: int main) students stdn change-name ( stdn, any additional input hereExplanation / Answer
struct studentRecord
{
int studentID;
string first_name;
string last_name;
int quiz1;
int quiz2;
int midTerm;
int finalExam;
double totalPoints;
double percentTotal;
char letterGrade;
};
void get_data(studentRecord& the_student)
{
//Check student ID
cout << " Enter Student Id ";
cin >> the_student.studentID;
//Check for mistakes
// Correct Value does this
if ((the_student.studentID> 1) || (the_student.studentID < 99999))
{
}
// Incorrect does this
// A loop To validate the Student ID
while ((the_student.studentID < 1) || (the_student.studentID > 99999))
{
cout <<" Must enter an Student ID between 1 and 99999. ";
cout <<"Re Enter Student ID: ";
cin >> the_student.studentID;
cout <<" ";
}
//Get First and last names
cout << " Enter First name ";
cin >> the_student.first_name;
cout << " Enter last name ";
cin >> the_student.last_name;
//Check Quiz 1 score
cout << " Enter quiz 1 score ";
cin >> the_student.quiz1;
//Check for mistakes
// Correct Value does this
if ((the_student.quiz1> 0) || (the_student.quiz1 < 25))
{
}
// Incorrect does this
// A loop To validate the quiz1
while ((the_student.quiz1 < 0) || (the_student.quiz1 > 25))
{
cout <<" Must enter an quiz1 score between 0 and 25. ";
cout <<"Re Enter quiz1 score: ";
cin >> the_student.quiz1;
cout <<" ";
}
//Check Quiz 2 score
cout << " Enter quiz 2 score ";
cin >> the_student.quiz2;
//Check for mistakes
// Correct Value does this
if ((the_student.quiz2> 0) || (the_student.quiz2 < 25))
{
}
// Incorrect does this
// A loop To validate the quiz2
while ((the_student.quiz2 < 0) || (the_student.quiz2 > 25))
{
cout <<" Must enter an quiz2 score between 0 and 25. ";
cout <<"Re Enter quiz2 score: ";
cin >> the_student.quiz2;
cout <<" ";
}
//Check Midterm
cout << " Enter Mid Term score ";
cin >> the_student.midTerm;
//Check for mistakes
// Correct Value does this
if ((the_student.midTerm> 0) || (the_student.midTerm < 50))
{
}
// Incorrect does this
// A loop To validate the midTerm
while ((the_student.midTerm < 0) || (the_student.midTerm > 50))
{
cout <<" Must enter an midTerm score between 0 and 50. ";
cout <<"Re Enter a midTerm score: ";
cin >> the_student.midTerm;
cout <<" ";
}
//Check Final
cout << " Enter Final Exam score ";
cin >> the_student.finalExam;
//Check for mistakes
// Correct Value does this
if ((the_student.finalExam> 0) || (the_student.finalExam < 100))
{
}
// Incorrect does this
// A loop To validate the finalExam
while ((the_student.finalExam < 0) || (the_student.finalExam > 100))
{
cout <<" Must enter an finalExam score between 0 and 100. ";
cout <<"Re Enter a finalExam score: ";
cin >> the_student.finalExam;
cout <<" ";
}
//Calculate Total Points
// This adds together all quizes and exams
the_student.totalPoints = the_student.quiz1 + the_student.quiz2 + the_student.midTerm + the_student.finalExam;
//Calulate Percentage in class
the_student.percentTotal = ((the_student.totalPoints * 100) / 200);
//Figure out letter grade
if (the_student.percentTotal>= 90)
{
the_student.letterGrade = 'A';
}
else if ((the_student.percentTotal>= 80) || (the_student.percentTotal < 90))
{
the_student.letterGrade = 'B';
}
else if ((the_student.percentTotal>= 70) || (the_student.percentTotal < 80))
{
the_student.letterGrade = 'C';
}
else if ((the_student.percentTotal>= 60) || (the_student.percentTotal < 70))
{
the_student.letterGrade = 'D';
}
else if (the_student.percentTotal<60)
{
the_student.letterGrade = 'F';
}
}
int main()
{
studentRecord student;
get_data(student);
//Show to first decimal place.
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << " Student ID = " << student.studentID <<"";
cout << " First Name = " << student.first_name <<"";
cout << " Last Name = " << student.last_name <<"";
cout << " Quiz 1 Score = " << student.quiz1 <<"";
cout << " Quiz 2 Score = " << student.quiz2 <<"";
cout << " Mid Term Score = " << student.midTerm <<"";
cout << " Final Exam Score = " << student.finalExam <<"";
cout << " Total Points = " << student.totalPoints <<"";
cout << " Percent Total = " << student.percentTotal <<"%";
cout << " Letter Grade = " << student.letterGrade <<" ";