Question: #include #include #include #include #include using namespace std; class Student { private: string fname; string lname; int test 1 ; int test 2 ; int

#include
#include
#include
#include
#include
using namespace std;
class Student {
private:
string fname;
string lname;
int test1;
int test2;
int assignment1, assignment2, assignment3, assignment4;
int attendance;
int inputValidate(int);
void getScore(int &);
void calcAverage(int a1, int a2, int a3, int a4);
int ifLowest(int a1, int a2, int a3, int a4);
int findLowest(int a1, int a2, int a3, int a4);
int average;
public:
Student();
Student(string f, string l, int t1, int t2, int a1, int a2, int a3, int a4, int attn);
~Student();
char getGrade();
bool isPassed();
float getAvg();
void print();
int testScore(){
return test1+ test2;
}
int assignmentScore(){
return assignment1+ assignment2+ assignment3+ assignment4;
}
};
void Student::print(){
cout << setw(10)<< fname << setw(10)<< lname << setw(5)<< testScore()<< setw(7)<< assignmentScore()<< setw(8)<< getAvg()<< setw(5)<< getGrade()<< setw(10)<<((isPassed())? "passed" : "failed")<< endl;
}
float Student::getAvg(){
return (test1*0.33+ test2*0.33+(assignment1+ assignment2+ assignment3+ assignment4)/4*0.33);
}
bool Student::isPassed(){
if (attendance <20)
return false;
if (getAvg()<60)
return false;
return true;
}
char Student::getGrade(){
float average = getAvg();
if (average >=90)
return 'A';
else if (average <90 && average >=80)
return 'B';
else if (average <80 && average >=70)
return 'C';
else if (average <70 && average >=60)
return 'D';
else
return 'F';
}
Student::Student(){}
Student::Student(string fn, string ln, int t1, int t2, int a1, int a2, int a3, int a4, int atten){
fname = fn;
lname = ln;
test1= t1;
test2= t2;
assignment1= a1;
assignment2= a2;
assignment3= a3;
assignment4= a4;
attendance = atten;
}
Student::~Student(){}
int main(){
ifstream ifile;
ifile.open("My grades.txt");
string line;
int count =0;
while (getline(ifile, line))
count++;
ifile.close();
ifile.open("My grades.txt");
vector students;
if (ifile.is_open()){
string fname, lname;
int test1, test2, assign1, assign2, assign3, assign4, atten;
for (int i =0; i < count; i++){
ifile >> fname >> lname >> test1>> test2>> assign1>> assign2>> assign3>> assign4>> atten;
students.push_back(Student(fname, lname, test1, test2, assign1, assign2, assign3, assign4, atten));
}
} else {
cout << "File not opened!" << endl;
return -1;
}
for (auto student : students){
student.print();
}
ifile.close();
void calcAverage,
int a1,
a2,
a3,
a4;
getScore(a1);
getScore(a2);
getScore(a3);
getScore(a4);
calcAverage(a1, a2, a3, a4);
return 0;
}
int inputValidate(int a)
{
while(!(cin >> a)||(a <0|| a >100))
{
cout << "Error. An integer from 0-100 must be entered: ";
cin.clear();
}
return num;
}
void getScore(int &a)
{
cout << "What is the testscore: ";
a = inputValidate(a);
}
int lowest;
int average;
void calcAverage(int a1,
int a2,
int a3,
int a4)
{
int findLowest;
int average;
lowest = findLowest(a1, a2, a3, a4);
if (a1== lowest)
average =(a2+ a3+ a4)/3;
else if (a2== lowest)
average =(a1+ a3+ a4)/3;
else if (a3== lowest)
average =(a1+ a2+ a4)/3;
else if (a4== lowest)
average =(a1+ a2+ a3)/3;
cout << "The average is: "<< average << endl;
}
int ifLowest( int a1,
int a2,
int a3,
int a4)
{
int lowest;
if (a1<= a2)
{
if (a1<= a3)
{
if (a1<= a4)
{
lowest = a1;
}
}
}
return lowest;
}
int findLowest(int a1,
int a2,
int a3,
int a4)
{
int smallest;
smallest = ifLowest(a1, a2, a3, a4);
smallest = ifLowest(a2, a3, a4, a1);
smallest = ifLowest(a3, a4, a1, a2);
smallest = ifLowest(a4, a1, a2, a3);
smallest = ifLowest(a1, a2, a3, a4);
return smallest;
return 0;
} THE programm wont run having problems with the error codes and need to remove or change the class , private , public and not use gobleal variuables

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!