I am running it with Microsoft Visual C plus plus 2010. Says that there is a bui
ID: 3652579 • Letter: I
Question
I am running it with Microsoft Visual C plus plus 2010. Says that there is a build error.#include <iostream>
using namespace std;
class record //contains values that are recorded
{
private:
double quiz1;
double quiz2;
double midyear, midyear_one;
double final, final_one;
double quiz_average;
char final_grade;
double total_grade;
public: void instructions()
{
cout << "Welcome to the program student record";
cout << endl << "this program takes in 2quizes, a final and midyear";
cout << endl << "and then calculates the average by what they are worth by";
cout << endl << "the quizes together are worth 25% and midyear counts for 25%";
cout << endl << "and the final counts for 50%"; cout << endl;
}
void input(record& the_grades)
{
cout << endl; cout << "Enter quiz 1 grade out of 10 points: ";
cin >> the_grades.quiz1; // gets value for quiz 1
while(the_grades.quiz1 > 10)
{
cout << "ERROR!: Invalid Value"; // Error check loop for quiz 1 and does not allow value for over 10 points
cout << endl;
cout << "Re- Enter Value for quiz 1: ";
cin >> the_grades.quiz1;// re-entered value for quiz 1
cout << endl;
}
cout << endl;
cout << "Enter quiz 2 grade out of 10 points: ";
cin >> the_grades.quiz2; // gets value for quiz 2
while(the_grades.quiz2 > 10) // Error check loop for quiz 2 and does not allow value for over 10 points
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for quiz 2: ";
cin >> the_grades.quiz2;// re-entered value for quiz 2 cout << endl;
}
cout << "Enter midyear Exam grade out of 100 points: ";
cin >> the_grades.midyear; // gets value for midyear exam
while(the_grades.midyear > 100) // Error check loop for midyear exam and does not allow value for over 100 points
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for Midyear Exam: ";
cin >> the_grades.midyear; // re entered value for midyear exam
cout << endl;
}
cout << endl;
cout << "Enter Final Exam grade out of 100 points: ";
cin >> the_grades.final; //gets value for final exam
while(the_grades.final > 100) // Error check loop for Final exam and does not allow value for over 100 points
{
cout << "ERROR!: Invalid Value";
cout << endl;
cout << "Re- Enter Value for Final Exam: ";
cin >> the_grades.final;// re-entered value for final exam
cout << endl;
}
cout << endl;
}
void output(record& the_grades)
{
the_grades.quiz_average = (((the_grades.quiz1/10) + (the_grades.quiz2/10))/2) * .25;
the_grades.final_one = (the_grades.final/100) * .5;
the_grades.midyear_one = (the_grades.midyear/100) *.25;
the_grades.total_grade = (the_grades.quiz_average + the_grades.final_one + the_grades.midyear_one) * 100;
cout << endl << endl;
cout <<"Quiz1: "<< (the_grades.quiz1/10)* 100 <<"% "; //displays quiz one percentage
cout << endl;
cout <<"Quiz2: "<< (the_grades.quiz2/10) * 100 <<"% ";//displays quiz two percentage
cout << endl;
cout <<"Midyear exam: " << the_grades.midyear<<"/100"; // displays midyear exam percentage
cout << endl;
cout <<"Final exam: " << the_grades.final<<"/100"; // displays final exam percentage
cout << endl;
cout <<"Final grade: "<< the_grades.total_grade <<" %"; // displays the final grade in percentage
cout << endl;
cout <<"Letter grade: ";
if(the_grades.total_grade <= 60.0) // if statesments to check which letter grade is recieved
{
cout << "F";
}
if((the_grades.total_grade >= 60.0)&&(the_grades.total_grade < 70.0))
{
cout << "D";
}
if((the_grades.total_grade >= 70.0)&&(the_grades.total_grade < 80.0))
{
cout << "C";
}
if((the_grades.total_grade >= 80.0)&&(the_grades.total_grade < 90.0))
{
cout << "B";
}
if(the_grades.total_grade >= 90.0)
{
cout << "A";
}
cout << endl;
}
};
int main()
{
char run_again; // variable to allow user to run program again record grades;
grades.instructions();// outputs instructions
do
{
grades.input(grades); // gets grades
grades.output(grades);// outputs the values
cout << endl << endl;
cout << "Run again?:";// asks user if the user wants to run again
cout << "(enter Y or N)";
cout << endl;
cin >> run_again;// if y then the program will run again
}
while((run_again == 'y')||(run_again == 'Y'));
cout << "";
cout << endl << endl;
system("pause");
return 0;
}
Explanation / Answer
there is 1 warning and 1 error in your code. Warning: write the definition of input() function outside the class don't try to make it inline function. Error: you didn't create the object of your class......i.e you are trying to access the instance function with the help of undefined object...in your case it is "grades.instructions()".
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.