Homework assistance only,I need to create an object from this class (StudentRecord) Call an input function of this object (not class) Call an output function of this object and I am okay until this point. How should it look? No errors until that section of code??????
#include <iostream>
usingnamespace std;
//define class StudentRecord before the main function
class StudentRecord {
//private variables must be created - exam1, exam2, average, lettergrade, studentID
private:
double exam1;
double exam2;
double average;
char lettergrade;
char studentID [5];
int objStudent;
// two public functions should be defined - input( ) and output( )
// input function contains all the cin statements to receive studentID, exam1 and exam2 scores
public:
void input () {
cout << "Enter the Student ID: ";
cin >> studentID;
cout << "Enter Exam 1 Score: ";
cin >> exam1 ;
cout << "Enter Exam 2 score: ";
cin >> exam2 ;
}
//output function contains the code to compute average and letter grade, and display all the information
void output () {
average = (exam1+exam2) / 2;
if (average<=100 && average>89)
lettergrade='A';
elseif (average<=89 && average>79)
lettergrade='B';
elseif (average<=79 && average>69)
lettergrade='C';
elseif (average<=69 && average>59)
lettergrade='D';
elseif (average<=59 && average>0)
lettergrade='F';
cout << "Student ID - " << studentID << endl;
cout << "Exam 1 score - " << exam1 << endl;
cout << "Exam 2 score - " << exam2 << endl;
cout << "Class average - " << average << endl;
cout << "Letter grade - " << lettergrade << endl;
};
//Main function contains three main code Create an object from this class (StudentRecord) Call an input function of this object (not class) Call an output function of this object
int main ()
{
StudentRecord objStudent;
input "()";
output "()"
system("PAUSE");
return 0;
}
Thank you all, I made the changes but am still getting two error messages:
I can't find the problem??????
[
#include <iostream>
using namespace std;
//define class StudentRecord before the main function
class StudentRecord {
//private variables must be created - exam1, exam2, average, lettergrade, studentID
private:
double exam1;
double exam2;
double average;
char lettergrade;
char studentID [5];
int objStudent;
// two public functions should be defined - input( ) and output( )
// input function contains all the cin statements to receive studentID, exam1 and exam2 scores
}
//output function contains the code to compute average and letter grade, and display all the information
void output () {
average = (exam1+exam2) / 2;
if (average<=100 && average>89)
lettergrade='A';
else if (average<=89 && average>79)
lettergrade='B';
else if (average<=79 && average>69)
lettergrade='C';
else if (average<=69 && average>59)
lettergrade='D';
else if (average<=59 && average>0)
lettergrade='F';
cout << "Student ID - " << studentID << endl;
cout << "Exam 1 score - " << exam1 << endl;
cout << "Exam 2 score - " << exam2 << endl;
cout << "Class average - " << average << endl;
cout << "Letter grade - " << lettergrade << endl;
};
//Main function contains three main code Create an object from this class (StudentRecord) Call an input function of this object (not class) Call an output function of this object
int main ()
{
StudentRecord objStudent;
objStudent.input ();
objStudent.output ();
system("PAUSE");
return 0;
}
}
]
59 expected unqualified-id at end of input
59 expected `,' or `;' at end of input
As has been pointed out several times, you're missing the closing brace for function output.
At line 48 in your OP, the }; terminates the class. You have no } terminating the output function.
And you now have an extraneous } in main.
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.