Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Rewritew this program replacing struct with class, note that all functions of th

ID: 3833637 • Letter: R

Question

Rewritew this program replacing struct with class, note that all functions of this program should be put inside the public section of the class and all data members in the private section of the class.

#include<iostream>
using namespace std;

struct record
{
double quiz1;
double quiz2;
double midyear, midyear_one;
double final, final_one;
double quiz_average;
char final_grade;
double total_grade;
};
void instructions();
void input(record& the_grades);
void output(record& the_grades);


int main()
{
char run_again;

record grades;

do
{
input(grades);
output(grades);
cout << endl << endl;
cout << "Run again?:";
cout << "(enter Y or N)";
cout << endl;
cin >> run_again;
}while((run_again == 'y')||(run_again == 'Y'));
cout << "<program end>";
cout << endl << endl;
return 0;
}

void input(record& the_grades)
{
cout << endl;
cout << "Enter quiz 1 grade out of 10 points: ";
cin >> the_grades.quiz1;
while(the_grades.quiz1 > 10)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for quiz 1: ";
cin >> the_grades.quiz1;
cout << endl;
}
cout << endl;
cout << "Enter quiz 2 grade out of 10 points: ";
cin >> the_grades.quiz2;
while(the_grades.quiz2 > 10)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for quiz 2: ";
cin >> the_grades.quiz2;
cout << endl;
}
cout << "Enter midyear Exam grade out of 100 points: ";
cin >> the_grades.midyear;
while(the_grades.midyear > 100)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for Midyear Exam: ";
cin >> the_grades.midyear;
cout << endl;
}
cout << endl;
cout << "Enter Final Exam grade out of 100 points: ";
cin >> the_grades.final;
while(the_grades.final > 100)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for Final Exam: ";
cin >> the_grades.final;
cout << endl;
}
cout << endl;
}
void output(record& the_grades)
{
the_grades.quiz_average = (((the_grades.quiz1/10) + (the_grades.quiz2/10))/2) * .25;
the_grades.final_one = (the_grades.final/100) * .5;
the_grades.midyear_one = (the_grades.midyear/100) *.25;
the_grades.total_grade = (the_grades.quiz_average + the_grades.final_one + the_grades.midyear_one) * 100;

cout << endl << endl;
cout <<"Quiz1: "<< (the_grades.quiz1/10)* 100 <<"% ";
cout << endl;
cout <<"Quiz2: "<< (the_grades.quiz2/10) * 100 <<"% ";
cout << endl;
cout <<"Midyear exam: " << the_grades.midyear<<"/100";
cout << endl;
cout <<"Final exam: " << the_grades.final<<"/100";
cout << endl;
cout <<"Final grade: "<< the_grades.total_grade <<" %";
cout << endl;
cout <<"Letter grade: ";
if(the_grades.total_grade <= 60.0)
{
cout << "F";
}
if((the_grades.total_grade >= 60.0)&&(the_grades.total_grade < 70.0))
{
cout << "D";
}
if((the_grades.total_grade >= 70.0)&&(the_grades.total_grade < 80.0))
{
cout << "C";
}
if((the_grades.total_grade >= 80.0)&&(the_grades.total_grade < 90.0))
{
cout << "B";
}
if(the_grades.total_grade >= 90.0)
{
cout << "A";
}
cout << endl;

}

Explanation / Answer

#include<iostream>
using namespace std;
class record
{
   private:
double quiz1;
double quiz2;
double midyear, midyear_one;
double final, final_one;
double quiz_average;
char final_grade;
double total_grade;
public:
  
void input(record& the_grades)
{
cout << endl;
cout << "Enter quiz 1 grade out of 10 points: ";
cin >> the_grades.quiz1;
while(the_grades.quiz1 > 10)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for quiz 1: ";
cin >> the_grades.quiz1;
cout << endl;
}
cout << endl;
cout << "Enter quiz 2 grade out of 10 points: ";
cin >> the_grades.quiz2;
while(the_grades.quiz2 > 10)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for quiz 2: ";
cin >> the_grades.quiz2;
cout << endl;
}
cout << "Enter midyear Exam grade out of 100 points: ";
cin >> the_grades.midyear;
while(the_grades.midyear > 100)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for Midyear Exam: ";
cin >> the_grades.midyear;
cout << endl;
}
cout << endl;
cout << "Enter Final Exam grade out of 100 points: ";
cin >> the_grades.final;
while(the_grades.final > 100)
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for Final Exam: ";
cin >> the_grades.final;
cout << endl;
}
cout << endl;
}

void output(record& the_grades)
{
the_grades.quiz_average = (((the_grades.quiz1/10) + (the_grades.quiz2/10))/2) * .25;
the_grades.final_one = (the_grades.final/100) * .5;
the_grades.midyear_one = (the_grades.midyear/100) *.25;
the_grades.total_grade = (the_grades.quiz_average + the_grades.final_one + the_grades.midyear_one) * 100;
cout << endl << endl;
cout <<"Quiz1: "<< (the_grades.quiz1/10)* 100 <<"% ";
cout << endl;
cout <<"Quiz2: "<< (the_grades.quiz2/10) * 100 <<"% ";
cout << endl;
cout <<"Midyear exam: " << the_grades.midyear<<"/100";
cout << endl;
cout <<"Final exam: " << the_grades.final<<"/100";
cout << endl;
cout <<"Final grade: "<< the_grades.total_grade <<" %";
cout << endl;
cout <<"Letter grade: ";
if(the_grades.total_grade <= 60.0)
{
cout << "F";
}
if((the_grades.total_grade >= 60.0)&&(the_grades.total_grade < 70.0))
{
cout << "D";
}
if((the_grades.total_grade >= 70.0)&&(the_grades.total_grade < 80.0))
{
cout << "C";
}
if((the_grades.total_grade >= 80.0)&&(the_grades.total_grade < 90.0))
{
cout << "B";
}
if(the_grades.total_grade >= 90.0)
{
cout << "A";
}
cout << endl;
}
};

int main()
{
char run_again;
record grades;
do
{
grades.input(grades);
grades.output(grades);
cout << endl << endl;
cout << "Run again?:";
cout << "(enter Y or N)";
cout << endl;
cin >> run_again;
}while((run_again == 'y')||(run_again == 'Y'));
cout << "<program end>";
cout << endl << endl;
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote