Question
Please finish the following c++ code by adding the remaining structs getTotal & getGrades getTotal: should get the addition from test1(20%), test2(20%), lab(15%), quiz(30%), final(30%)
Please finish the following c++ code by adding the remaining structs getTotal & getGrades
getTotal: should get the addition from test1(20%), test2(20%), lab(15%), quiz(30%), final(30%) and divide them by (10) to get a grade from (1.00-10.00)
getGrade: Use switch method to assign a letter grade based on their total grade (1.00-10.00)
The program must get access from a txt file (scores.txt), and output the information in another txt file (studentout.txt)
scores.txt must contain this info:
Name Test1 test2 lab quiz final total grade
Ram M. Garza 98 94 89 96 94
Matt T. Mills 67 63 61 67 60
Miguel Z. Garcia 77 71 79 68 70
Omar T. Smith 83 80 81 89 85
Laura M. Moore 55 56 57 60 63
Same code in txt:
#include
#include
#include
#include
#include
using namespace std;
struct studentType
{
string first_name;
string middle_name;
string last_name;
int test1;
int test2;
int lab;
int quiz;
int final;
int total;
char grade;
};
const int SIZE = 5;
void openInputFile(ifstream &, string, studentType[]);
void getTotal(studentType[]);
void getGrade(studentType[]);
void print(studentType[]);
int main()
{
studentType students[SIZE];
int count = 0;
ifstream inFile;
string inFileName = "scores.txt";
openInputFile(inFile, inFileName, students);
//getTotal(students);
//getGrades(students);
print(students);
cout
return 0;
}
void openInputFile(ifstream &inFile, string inFileName, studentType str[SIZE])
{
inFile.open(inFileName);
if (!inFile)
{
cout
cout
return;
}
else
{
for (int count = 0; count
{
inFile >> str[count].first_name >> str[count].middle_name >> str[count].last_name
>> str[count].test1 >> str[count].test2 >> str[count].lab
>> str[count].quiz >> str[count].final;
}
}
inFile.close();
}
void print(studentType arr[])
{
ofstream out("studentout.txt");
cout
cout
out
out
for (int i=0; i
{
string name;
name = arr[i].first_name + " " +arr[i].middle_name + " " + arr[i].last_name;
cout
//
cout
out
//
out
}
}
include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started