CSC134 Lab 1 Page 3 Program Description: Write a program to generate a report ba
ID: 3684735 • Letter: C
Question
CSC134 Lab 1 Page 3 Program Description: Write a program to generate a report based on input received from a text file. Suppose the input text file student status.txt contains the student's name (lastName, firstName middleName) and average as follows: Doe, John K. 93.2 Andrews, Susan S 84.7 Monroe, Marylin 75.1 Gaston, Arthur C. 62.8 Using the test file that is provided on Blackboard, generate the output in the following format, exactly: Doe, John K. 93.2 A Andrews, Susan S. 84.7 B Monroe, Marylin 75.1 C Gaston, Arthur C. 62.8 D The program must be written to use the enum letter_grade, defined as follows: enum letter_grade A, B, C, D, F 1; and define two namespace globalTypes (tenPoint and sevenPoint) for the function letter_grade deriveGrade (double average); The function deriveGrade should derive the letter_grade of the student based on the student's average The first namespace globalType tenPoint should derive the class level based on a ten point grading scale and the second namespace globalType sevePoint should derive the class level based on a seven point grading scale. The scales are provided belowExplanation / Answer
The program must be written to use the enum class_level :
The function deriveClassLevel should derive the class_level of the student based on the number of credits earned.
The first namespace globalType tys should derive the class level based on a two year school policy.
and the second namespace globalType fys should derive the class level based on a four year school policy.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
enum class_level { FRESHMAN, SOPHOMORE, JUNIOR, SENIOR };
int main()
{
string uplevel, name;
int noc, id, i;
class_level level = FRESHMAN;
ifstream transferSchoolFile;
transferSchoolFile.open("student_status.txt", ios::in);
//check for error
if (transferSchoolFile.fail()){
cerr << "Error opening file" << endl;
exit(1);
}
for (i = 0; i < 4; i++)
{
getline(transferSchoolFile, name);
transferSchoolFile >> id >> noc;
transferSchoolFile.ignore();
if (noc < 30)
{
level = FRESHMAN;
}
else if (noc < 60 && noc > 29)
{
level = SOPHOMORE;
}
else if (noc > 59 && noc < 90)
{
level = JUNIOR;
}
else
level = SENIOR;
switch (level)
{
case FRESHMAN:
uplevel = "Freshman";
break;
case SOPHOMORE:
uplevel = "Sophomore";
break;
case JUNIOR:
uplevel = "Junior";
break;
default:
uplevel = "Senior";
}
cout << name << " " << id << " " << noc << " " << uplevel << endl;
}
system("pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
enum class_level { FRESHMAN, SOPHOMORE, JUNIOR, SENIOR };
class_level classLevel;
namespace tys
{
class_level deriveClassLevel(int noc)
{
if (noc >= 0 && noc <= 29)
{
classLevel = FRESHMAN;
}
else
{
classLevel = SOPHOMORE;
}
}
namespace fys
{
class_level deriveClassLevel(int noc)
{
if (noc >= 0 && noc <= 29)
{
classLevel = FRESHMAN;
}
else if (noc >= 30 && noc <= 59)
{
classLevel = SOPHOMORE;
}
else if (noc >= 60 && noc <= 89)
{
classLevel = JUNIOR;
}
else
{
classLevel = SENIOR;
}
}
using namespace tys;
int main()
{
string uplevel, name;
int noc, id, i;
class_level level = FRESHMAN;
ifstream transferSchoolFile;
transferSchoolFile.open("student_status.txt", ios::in);
//check for error
if (transferSchoolFile.fail()){
cerr << "Error opening file" << endl;
exit(1);
}
for (i = 0; i < 4; i++)
{
getline(transferSchoolFile, name);
transferSchoolFile >> id >> noc;
transferSchoolFile.ignore();
switch (level)
{
case FRESHMAN:
uplevel = "Freshman";
break;
case SOPHOMORE:
uplevel = "Sophomore";
break;
case JUNIOR:
uplevel = "Junior";
break;
default:
uplevel = "Senior";
}
cout << name << " " << id << " " << noc << " " << uplevel << endl;
}
system("pause");
return 0;
}
}
}