i have to make the C++ program that will have the user input some test grades and exam grades and their personal info then output their stuff in the end. i have almost the whole thing done, but i would compile it throws up a list of 30 erros and i am having troble with it. i think it looks good but im still not all that good with this stuff please help. here is the code

[LIST=1]
[*]#include <iostream>
[*]#include <string>
[*]using namespace std;

[*]class Grade
[*]{
[*]private:
[*]	string firstName;
[*]	string lastName;
[*]	int idNum;
[*]	int numHomeworks;
[*]	int numExams;
[*]	int listSize;
[*]	int score;
[*]	int grades;
[*]	

[*]public:
[*]	void getStudentInfo();
[*]	void getExamGrades(grades, Grade::numExams);
[*]	void getHWGrades(grades, Grade::numExams, listSize);
[*]	void calcTotalPoints(grades, listSize);
[*]	void calcLetterGrade();
[*]	void displayInfo();
[*]	void setID(int id);
[*]	void setScore(int grades);
[*]	void setExams(int exams);
[*]	void setName(string fn, string ln);

[*]	

[*]	
[*]	Grade(string, string, int, int, int, int);
[*]};


[*]Grade::Grade(string fn, string ln, int id, int grades; int exams, int listSize)
[*]{
[*]	firstName = fn;
[*]	lastName = ln;
[*]	idNum = id;
[*]	grades = grades;
[*]	numExams = exams;
[*]	listSize = listSize;
[*]}

[*]void Grade::setID(int id)
[*]{
[*]	idNum = id;
[*]}
[*]void Grade::setScore(int grades)
[*]{
[*]	grades = grades;
[*]}

[*]void Grade::setExams(int exams)
[*]{
[*]	numExams = exams;
[*]}

[*]void Grade::setName(string fn, string ln)
[*]{
[*]	firstName = fn;
[*]	lastName = ln;
[*]}
[*]void Grade::getStudentInfo()
[*]{
[*]	cout << "First Name: " << endl;
[*]	cin >> firstName;
[*]	cout <<"Last Name: " <<endl;
[*]	cin >> lastName;
[*]	cout <<"ID: "<<endl;
[*]	cin >>idNum;
[*]}
[*]void Grade::getExamGrades(grades, Grade::numExams)
[*]{
[*]	
[*]	cout <<"Score for Exam #1: "<<endl;
[*]	cin >> numExams;
[*]	cout <<"Score for Exam #2: "<<endl;
[*]	cin >> numExams;
[*]	
[*]}
[*]void Grades::getHWGrades(grades, Grade::numExams, listSize)
[*]{
[*]	cout <<"Score for Homework #1: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #2: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #3: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #4: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #5: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #6: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #7: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #8: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #9: "<<endl;
[*]	cin >> grades;
[*]	cout <<"Score for Homework #10: "<<endl;
[*]	cin >> grades;
[*]}

[*]void Grade::calcTotalPoints(grades, listSize)
[*]{
[*]	grade*10+numExams*2=score
[*]	
[*]}
[*]void Grade::calcLetterGrade();
[*]{
[*]	if (score < 59)
[*]	{
[*]		cout << " Letter grade is F" << endl;
[*]	}
[*]	if (score == 60)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 69)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 68)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 67)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 66)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 65)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 64)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 63)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 62)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 61)
[*]	{
[*]		cout << " Letter grade is D" << endl;
[*]	}
[*]	if (score == 70)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 71)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 72)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 73)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 74)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 75)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 76)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 77)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 78)
[*]	{
[*]		cout << " Letter grade is C "<< endl;
[*]	}
[*]	if (score == 79)
[*]	{
[*]		cout << " Letter grade is C" << endl;
[*]	}
[*]	if (score == 80)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 81)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 82)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 83)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 84)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 85)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 86)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 87)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 88)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score == 89)
[*]	{
[*]		cout << " Letter grade is B" << endl;
[*]	}
[*]	if (score > 90)
[*]	{
[*]		cout << " Letter grade is A" << endl;
[*]	}
[*]}

[*]void Grade::displayInfo()
[*]{
[*]	cout<<"-----Grade Report-----"<<endl;
[*]	cout<<"Student #: "<<idNum<<endl;
[*]	cout<<"Name: "<<firstName<<" "<<lastName<<endl;
[*]	cout<<"Total Points: "<<score<<endl;
[*]	cout<<"Grade: "<<myGrade.calcLetterGrade<<endl;
[*]}


[*]void main()
[*]{
[*] Grade myGrade; // declare a Grade object
[*] const int listSize = Grade::numExams + Grade::numHomeworks; // determine array size
[*] int grades[listSize]; // create array
[*] myGrade.getStudentInfo(); 
[*]    // Prompt for and obtain first name, last name, and id
[*]    // Ensures that the value entered for id is exactly 4 digits
[*] myGrade.getExamGrades(grades, Grade::numExams);
[*]    // Prompts for and reads in the exam scores
[*]    // Ensures that exam scores are not less than zero
[*] myGrade.getHWGrades(grades, Grade::numExams, listSize);
[*]    // Prompts for and reads in the homework scores
[*]    // Ensures that homeworks scores are greater than zero and less than 26
[*] myGrade.calcTotalPoints(grades, listSize);
[*]    // Calculates total points (data member)
[*]    // Prompts for and obtains office visit value (and includes it in total points)
[*] myGrade.calcLetterGrade();
[*]    // Determines letter grade (data member) 
[*] myGrade.displayInfo();
[*]    // Outputs all data member values (with formatting text)
[*]}
[/LIST]

If you see any errors ar anyway that i could get this to compile please let me know. i would really apreciate it. thanks

P.S. i also attached both the .cpp file and the compiler output tex file aswell.

Recommended Answers

All 2 Replies

Wow... Before worrying about getting it to compile, you might want to think about writing a design document to get your logic straight.

But...
Your error log tells you what is wrong. In your class declaration, you aren't referring to valid types, you are referring to your own names for things. Problem.

main isn't a void function.

You declare Grade::numExams and Grade::grades as private, and non-static, then immediately try to use them in a public fashion in main. At this point they are A) unaccessible, and B) uninitialized.

In your class, er, how many of your actual homework assignment grades get recorded somewhere? Well, all of them, but only #10 matters, since you keep overwriting the same variable. Ditto the exam grades, except there you only overwrite once.

CalcLetterGrade... er, isn't there perhaps a better method of doing this? Maybe with relational operators? And you miss the case where grade is 90.

Again, the errors list is pretty good, why not work through that from the first down, recompiling every time you fix something.

Incremental Compiles are always better than just writing a bunch of code and preying for the best.

Thanks for the help. I wouldn't have able to get it figured out without you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.