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: 3765934 • 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<string.h>
# include<fstream.h>
#include <sstream>

using namespace std;
void r_w_file();
char grade(string);

void main()
{
r_w_file()
}
void r_w_file()
{
string line;
string arr[6];
char gr[4];
int i;
ifstream myfile ("example.txt");
ofstream mf;
mf.open("asd.txt",ios::app);
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
  

stringstream ssin(line);
for(i=0;i<6;i++)
ssin >> arr[i];

for(i=0,j=3;j<6;j++,i++)
gr[i] = grade(arr[j]);
mf<<arr[0]<<" "<<arr[1]<<" "<<gr[0]<<" "<<gr[1]<<" "<<gr[2]<<" "<<gr[3]<<" "
}
myfile.close();
}

  
mf.close();
}

char grade(string mark)
{
int m = atoi(mark.c_str());char g;

if(m >=90 && m <=99)
g='A';
else if(m >=80 && m <=89)
g='B';
else if(m >=70 && m <=79)
g='C';
else if(m >=60 && m <=69)
g='D';
else
g='F';

return g;
}