Getting incorrect values from grading program

Not sure what the problem is here, I have checked the arithmetic and can't find any reason why I'm getting incorrect values for the final grade percentage. Below is the entire program, any help is greatly appreciated.

EDIT: Edited for correct solution in case this comes up in google one day

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>

using namespace std;

const double quizWeight = 12.5, midtermWeight = 25.0, finalWeight = 50.0; // These weights are percentages of the final course grade.

class student_record
{

private:
	double quiz1, quiz2, midterm, finalExam;  // Actual score for the tests.
	double quiz1Points, quiz2Points, midTermPoints, finalExamPoints;  // Points earned from respective tests.
	double percentFinalGrade;  // Final grade in percentage
	char finalGrade; // Final grade after setLetterGrade

public:
	void Introduction();   // Program Introduction
	void setScores();  // Takes user input and sets the score value for quizzes and exams, has loop mechanism
	void scoreToPoints();  // Converts all student scores to points earned
	void setPercentGrade();  // Converts points earned to a total grade percentage for the class
	void setLetterGrade(); // Converts percentFinalGrade to finalGrade (A, B, C, D, F)
	void closingOutput(); // Displays all information to the user

};

int main()
{
	student_record current_record;
	current_record.Introduction(); 

	char choice;
	do
	{
	current_record.setScores();
	current_record.scoreToPoints();
	current_record.setPercentGrade();
	current_record.setLetterGrade();
	current_record.closingOutput();

	cout << "Would you like to enter new grades? (Y or N): ";
	cin >> choice;
	cout << endl;
	} while (choice == 'Y' || choice == 'y');

	return 0;
}

	void student_record::Introduction()
	{
		cout << setw(47) << "<::PROGRAM INFO::>" << endl
			 << "The student record program allows you to enter 2 quiz scores, a midterm score\n and a final exam score for your students. The program will then calculate"
			 << "\nthe students final grade for the course and output a letter grade.\n"
			 << "Enjoy!" << endl << endl;
	}
	void student_record::setScores()
{
	char correct;
	do {
	cout << "Please round score inputs to within 2 decimal points, such as 95.55." << endl;
	cout << "Enter the students score for quiz one: " << endl;
	cin >> quiz1;
	cout << "Enter the students score for quiz two: " << endl;
	cin >> quiz2;
	cout << "Enter the students midterm score: " << endl;
	cin >> midterm;
	cout << "Enter the students final exam score: " << endl;
	cin >> finalExam;

	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(2);
	cout << "You entered: \n\n" << "Quiz 1:    " << "Quiz 2:     " << "Midterm:     " << "Final Exam:     " << endl
		 << quiz1 << setw(11) << quiz2 << setw(14) << midterm << setw(14) << finalExam << endl
		 << "Is this correct? (Y or N): " << endl;
	cin >> correct;
	}
	while (correct == 'n' || correct == 'N');

}
	void student_record::scoreToPoints()
	{
		quiz1Points = 10 * (quiz1 / 100);
		quiz2Points = 10 * (quiz2 / 100);
		midTermPoints = midterm;
		finalExamPoints = finalExam;

	}
	void student_record::setPercentGrade()
	{
		double quiz1Worth, quiz2Worth, midTermWorth, finalExamWorth;
		
		quiz1Worth = (quiz1Points / 10) * quizWeight;
		quiz2Worth = (quiz2Points / 10) * quizWeight;
		midTermWorth = (midTermPoints /100) * midtermWeight;
		finalExamWorth = (finalExamPoints / 100) * finalWeight;

		percentFinalGrade = (quiz1Worth + quiz2Worth) + (midTermWorth + finalExamWorth);

	}
	void student_record::setLetterGrade()
	{
		if(percentFinalGrade >= 90)
		{
			finalGrade = 'A';
		}
		else if (percentFinalGrade >= 80 && percentFinalGrade < 90)
		{
			finalGrade = 'B';
		}
		else if (percentFinalGrade >= 70 && percentFinalGrade < 80)
		{
			finalGrade = 'C';
		}
		else if (percentFinalGrade >= 60 && percentFinalGrade < 70)
		{
			finalGrade = 'D';
		}
		else {
			finalGrade = 'F';
		}

	
	}
	void student_record::closingOutput()
	{
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(2);
	cout << "\nThe students scores were: \n" << "Quiz 1:    " << "Quiz 2:     " << "Midterm:     " << "Final Exam:     " << endl
		 << "  " << quiz1 << setw(11) << quiz2 << setw(12) << midterm << setw(14) << finalExam << endl << endl
		 << "<<::Average Grade::>>" << endl << setw(12) << percentFinalGrade << endl
		 << "The students final letter grade is: " << finalGrade << endl;

	}
Last edited on
midTermWorth = (midTermPoints /1000) * midtermWeight;

I haven't gone through all of the math, but I would expect /100 not /1000.
Wow... Don't know how I missed that, it's working fine now.
Thanks you!
Topic archived. No new replies allowed.