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

In C++ Create a Student class which will contain the following A String object t

ID: 3765722 • Letter: I

Question

In C++

Create a Student class which will contain the following

A String object to hold a student’s first name

A String object to hold a student’s last name

An array object to hold four integers representing student’s grades in four different courses

A method to read the student data from a file. The student data in the file is formatted as follows (one line per student):

first name, a space, last name, a space, four integer values separated by space

A method to write to a file after the converting the numeric grade to letter grade

90 – 99: A

80 – 89: B

70 – 79: C

60 – 69: D

< 60     : F

Write a line for each student using the following format

Student’s first name in 20 characters, a space, last name in 10 characters, a space

Student’s letter grades separated by space

For students, the data in the input file is recorded as follows:

John Smith 93 66 87 58

Peter Pan 86 78 95 83

The output in the file for these students should look like

John                 Smith      A D B F

Peter                Pan          B C A B

Explanation / Answer

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
int count;
int LabExercises;
string firstname, lastname;
int lab1;
int lab2;
int lab3;
int lab4;
int lab5;
int lab6;
int lab7;
int lab8;
int lab9;
int lab10;
int AverageLabGrade;
int Homework;
int homework1;
int homework2;
int homework3;
int homework4;
int homework5;
int homework6;
int homework7;
int homework8;
int AverageHomeworkGrade;
int Midterm;
int Final;
int Total;
ifstream intfile;
ofstream outfile;


intfile.open("inputfile.txt");
outfile.open("outfile.txt");
if (!intfile) // Opening failed
{
cout << "Unable to open" << endl;

return 1;
}


intfile >> firstname >> lastname >> lab1 >> lab2 >> lab3 >> lab4 >> lab5 >> lab6 >> lab7 >> lab8 >> lab9 >> lab10 >> homework1 >> homework2 >> homework3 >> homework4 >> homework5 >> homework6 >> homework7 >> homework8 >> Midterm >> Final;
while (intfile)
{
count=0;
while (count < 20)
{

outfile << firstname << lastname << endl;


intfile >> firstname >> lastname >> lab1 >> lab2 >> lab3 >> lab4 >> lab5 >> lab6 >> lab7 >> lab8 >> lab9 >> lab10 >> homework1 >> homework2 >> homework3 >> homework4 >> homework5 >> homework6 >> homework7 >> homework8 >> Midterm >> Final;
count++;


//Print Average Grade
AverageLabGrade=((lab1+lab2+lab3+lab4+lab5+lab6+lab7+lab8+lab9+lab10)/10)*0.2;

outfile << "Average Lab Grade is: " << AverageLabGrade << endl;

//Print Homework grade

AverageHomeworkGrade=((homework1+homework2+homework3+homework4+homework5+homework6+homework7+homework8)/8)*0.1;

outfile << "Average Homework Grade is: " << AverageHomeworkGrade << endl;

//Print Midterm grade

Midterm=Midterm*0.3;
outfile << "Midterm Grade is: " << Midterm << endl;

//Print Final grade

Final=Final*0.4;
outfile << "Final Exam Grade is: " << Final << endl;

//Print Total
Total=(AverageLabGrade+AverageHomeworkGrade+Midterm+Final);

outfile << "Final Course Grade is: " << Total << endl;

if (Total >= 90)
outfile << "You Got A " << endl;
else if (Total >= 85 && Total <= 90)
outfile << " You Got A- " << endl;
else if (Total >= 80 && Total <= 85)
outfile << " You Got B+" << endl;
else if (Total >= 75 && Total <= 80)
outfile << " You Got B " << endl;
else if (Total >= 70 && Total <= 75)
outfile << " You Got B-" << endl;
else if (Total >= 65 && Total <= 70)
outfile << " You Got C+ " << endl;
else if (Total >= 60 && Total <= 65)
outfile << " You Got C" << endl;
else if (Total >= 55 && Total <= 60)
outfile << " You Got C- " << endl;
else if (Total >= 50 && Total <= 55)
outfile << " You Got D+" << endl;
else if (Total >= 45 && Total <= 50)
outfile << " You Got D " << endl;
else if (Total >= 40 && Total <= 45)
outfile << " You Got D-" << endl;
else if (Total >= 0 && Total <= 40)
outfile << " You Got F" << endl;

}

intfile >> firstname >> lastname >> lab1 >> lab2 >> lab3 >> lab4 >> lab5 >> lab6 >> lab7 >> lab8 >> lab9 >> lab10 >> homework1 >> homework2 >> homework3 >> homework4 >> homework5 >> homework6 >> homework7 >> homework8 >> Midterm >> Final;


}




return 0;
}