So many things wrong with this... Sorry, but it's true.
First:
1 2 3 4 5 6
|
class StudentRecord
{
public:
Student()
Student(string theID, String theExam1, String theExam2, String theAverage, String theLetter);
void average()const;
|
Student is defined twice... And it has no return value... I would actually recommend that it should be the constructor, because it looks like you're initializing all the variables...
1 2 3 4 5
|
class StudentRecord
{
public:
StudentRecord(string theID, String theExam1, String theExam2, String theAverage, String theLetter);
void average();
|
Oh, and you're going to calculate the letter later on, so that can go as well... Unless you're going to expand the program and need to have that variable in there... In any case, leave it out of the constructor so you can calculate it later, unless you want to calculate the letter grade in the constructor... Blah blah blah... And you don't have a average function, so it should look like this now:
1 2 3 4
|
class StudentRecord
{
public:
StudentRecord(string theID, String theExam1, String theExam2);
|
Look at this:
1 2 3 4
|
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
|
letterGrade=(finalGrade);
void letterGrade(int finGrade){
Nothing wrong? Nope... You need to tell the compiler that there is a function at the end to compile:
1 2 3 4 5
|
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
void letterGrade(int finGrade);
|
Oh, this is wrong as well:
letterGrade=(finalGrade);
Think about it...
I'll just tell you:
char TheLetterGrade = letterGrade(average);
Which also makes this wrong (very, very wrong):
1 2 3 4 5 6 7 8 9 10 11
|
void letterGrade(int finGrade){ //Determines Letter Grade
if(finGrade>=90)
cout << "A";
else if(finGrade>=80 && finGrade<90)
cout << "B";
else if(finGrade>=70 && finGrade<80)
cout << "C";
else if(finGrade>=60 && finGrade<70)
cout << "D";
else if(finGrade<60)
cout << "F";
|
Make it look a little more like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
void letterGrade(int finGrade)
{
if(finGrade>=90)
{
return 'A';
}
else if(finGrade>=80 && finGrade<90)
{
return 'B';
}
else if(finGrade>=70 && finGrade<80)
{
return 'C';
}
else if(finGrade>=60 && finGrade<70)
{
return 'D';
}
else if(finGrade<60)
{
return 'F';
}
}
|
Why make variables you don't use?
1 2 3 4 5 6 7
|
String ID, String Exam1, String Exam2;
cout << "Enter The Student ID:"<< endl;
cin student.id;
cout << "Enter Exam1" << endl;
cin >> grade.exam1;
cout << "Enter Exam2" << endl;
cin >> grade.exam2;
|
You'll also have to make a instance of you class... And fix the variable type and cin to the right things... So here:
1 2 3 4 5 6 7 8 9
|
int ID;
int Exam1;
int Exam2;
cout<<"Enter The Student ID: ";
cin>>ID;
cout<<"Enter Exam1: ";
cin>>Exam1;
cout<<"Enter Exam2: ";
cin>>Exam2
|
I didn't make an instance of the class, here is why:
USE and make your class:
StudentRecord MyStudent(ID, Exam1, Exam2);
Ya... Sorry if I came across as an asshole... Message back if you still need help!
- Kyle