Using multiple functions to grade and average scores

Ok, so I've been working on this program for most of the day and I'm a bit tired but this program has me stumped. It's a bit of a read but for this assignment, I'm needing to use 4 functions, the averageGrade function, the classAverage function with its respected weighted percentages (Lab – 50%, Tests – 40%, Project – 10%), getLetterGrade function, and displayGradeReport function that will display a grade report of each individual average along with their overall average and letter grade. I'm kinda confused about where to go from where I am currently, this is a lot to ask but any help is apreacciated!


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
#include <iostream>
#include <iomanip>
using namespace std;

//FUNCTIONS
double averageGrade();
int classAverage (double labAverage, double testAverage, double projectAverage);
void getLetterGrade (double gradeAverage, char determineGrade);
void displayGradeReport (double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade);

//MAIN
int main()
{
	//DECLARATIONS
	double labAverage = 0.0;
	double testAverage = 0.0;
	double projectAverage = 0.0;
	char determineGrade = ' ';
	double gradeAverage = 0.0;
	//Statements
	cout << "Please Enter The Lab Grades: " << endl;
	cin >> labAverage;
	labAverage = averageGrade();

	cout << "Please Enter The Test Grades: " << endl;
	cin >> testAverage;
	testAverage = averageGrade();

	cout << "Please Enter The ProjectGrades: " << endl;
	cin >> projectAverage;
	projectAverage = averageGrade();

	//FUNCTIONS
	classAverage (labAverage, testAverage, projectAverage);
	getLetterGrade (gradeAverage, determineGrade);
	displayGradeReport (labAverage, testAverage, projectAverage, gradeAverage, determineGrade);
	
	//END STUFFS
	system("pause");
	system("cls");
	cout << "Thanks For Stopping By!";
	return 0;
}
	//FUNCTIONS IN USE
	double averageGrade()
	{
		double gradeAverageOption = 0.0;
		double gradeTotal = 0.0;
		int numGrades = 0;
		double average = 0.0;
		
		while (gradeAverageOption != -1)
			{
			cout << "Please Enter The Grades Please OR PRESS (-1) TO EXIT: " << endl;
			cin >> gradeAverageOption;
			gradeTotal += gradeAverageOption;
			}
		average = (gradeTotal + 1) / (numGrades - 1);
		return average;
	}
	
	//NEXT FUNCTION
	int classAverage(double labAverage, double testAverage, double projectAverage)
	{
			
	}
	
	//NEXT FUNCTION
	void getLetterGrade(double gradeAverage, char detmineGrade) 
	{
		char letterGrade = ' ';
	
	}
	
	//NEXT FUNCTION
	void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade)
	{
		cout << "     Your MidTerm Grades Are   " << endl;
	
	}
Last edited on
Well you don't specify the grade boundaries - so as a starter perhaps something like (not tried):

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
#include <iostream>
#include <iomanip>
using namespace std;

double averageGrade();
double classAverage(double labAverage, double testAverage, double projectAverage);
void getLetterGrade(double gradeAverage, char determineGrade);
void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade);

int main() {
	cout << "Please Enter The Lab Grades\n";
	const auto labAverage {averageGrade()};

	cout << "Please Enter The Test Grades\n";
	const auto testAverage {averageGrade()};

	cout << "Please Enter The ProjectGrades\n";
	const auto projectAverage {averageGrade()};

	const auto clasAvg {classAverage(labAverage, testAverage, projectAverage)};
}

double averageGrade() {
	double gradeAverageOption {};
	double gradeTotal {};
	size_t numGrades {};

	while (gradeAverageOption != -1) {
		cout << "Please enter the grades -1 to exit: ";
		cin >> gradeAverageOption;
		gradeTotal += gradeAverageOption;
		++numGrades;
	}

	return (gradeTotal + 1) / (numGrades - 1);
}

double classAverage(double labAverage, double testAverage, double projectAverage)
{
	constexpr unsigned labWght {50};
	constexpr unsigned testWght {40};
	constexpr unsigned prjWght {10};

	static_assert(labWght + testWght + prjWght == 100);

	return (labAverage * labWght + testAverage * testWght + projectAverage * prjWght) / 100.0;
}

void getLetterGrade(double gradeAverage, char detmineGrade)
{
	char letterGrade = ' ';

}

void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade)
{
	cout << "     Your MidTerm Grades Are   " << endl;

}

Yeah I'm terrible with explanations lol, I've managed to get a good bit done but my calculations are still coming out messed up for some reason.

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
#include <iostream>
#include <iomanip>
using namespace std;

//FUNCTIONS
double averageGrade();
double classAverage(double labAverage, double testAverage, double projectAverage);
void getLetterGrade(double gradeAverage, char& determineGrade);
void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade);

//MAIN
int main()
{
	cout << fixed << setprecision(1);
	
	//DECLARATIONS
	double labAverage = 0.0;
	double testAverage = 0.0;
	double projectAverage = 0.0;
	char determineGrade = ' ';
	double gradeAverage = 0.0;
	do {
		//Statements
		cout << "For Lab Grades" << endl;
		labAverage = averageGrade();
		labAverage = classAverage(labAverage, testAverage, projectAverage);
		system("cls");
		cout << "For Test Grades" << endl;
		testAverage = averageGrade();
		testAverage = classAverage(labAverage, testAverage, projectAverage);
		system("cls");
		cout << "For ProjectGrades " << endl;
		projectAverage = averageGrade();
		projectAverage = classAverage(labAverage, testAverage, projectAverage);
		
		gradeAverage = classAverage(labAverage, testAverage, projectAverage);

		//FUNCTIONS
		getLetterGrade(gradeAverage, determineGrade);
		displayGradeReport(labAverage, testAverage, projectAverage, gradeAverage, determineGrade);

		//END STUFFS
		system("pause");
		system("cls");
		cout << "Thanks For Stopping By!";
	} while (gradeAverage != -1);
	return 0;
}
//FUNCTIONS IN USE
double averageGrade()
{
	double weightedAverage = 0.0;
	double gradeAverageOption = 0.0;
	double gradeTotal = 0.0;
	int numGrades = 0;
	double average = 0.0;

	while (gradeAverageOption != -1)
	{
		cout << endl;
		cout << "Please Enter The Grades Please OR PRESS (-1) TO EXIT: " << endl;
		cin >> gradeAverageOption;
		gradeTotal += gradeAverageOption;
		numGrades++;
	}
	average = (gradeTotal + 1) / (numGrades - 1);
	gradeTotal = (gradeTotal + average) / .5;
	return average;
}

//NEXT FUNCTION
double classAverage(double labAverage, double testAverage, double projectAverage)
{
	double weightedAverage = 0.0;
	labAverage = labAverage * .5;
	testAverage = testAverage * .4;
	projectAverage = projectAverage * .1;
	weightedAverage = (labAverage + testAverage + projectAverage);
	return weightedAverage;
}

//NEXT FUNCTION
void getLetterGrade(double gradeAverage, char& determineGrade)
{
		if (gradeAverage >= 90)
		determineGrade = 'A';
		else if (gradeAverage < 90 && gradeAverage >= 80)
		determineGrade = 'B';
		else if (gradeAverage < 80 && gradeAverage >= 70)
		determineGrade = 'C';
		else if (gradeAverage < 70 && gradeAverage >= 60)
		determineGrade = 'D';
		else if (gradeAverage < 60) 
		determineGrade = 'F';
}
	
	//NEXT FUNCTION
	void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade)
	{
		system("cls");
		cout << "                           *********************  Your MidTerm Grades Are  ********************" << endl;
		cout << "                           --------------------------------------------------------------------" << endl;
		cout << "*****Your Lab average Is: " << setw(9) << labAverage << endl << endl;
		cout << "****Your Test Average Is: " << setw(9) << testAverage << endl << endl;
		cout << "*Your Project Average Is: " << setw(9) << projectAverage << endl << endl;
		cout << "***Your Class Average Is: " << setw(9) << gradeAverage << setw(3) << determineGrade << endl << endl;
	}
Possibly:

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
#include <iostream>
#include <iomanip>
using namespace std;

double averageGrade();
double classAverage(double labAverage, double testAverage, double projectAverage);
void getLetterGrade(double gradeAverage, char& determineGrade);
void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade);

int main() {
	cout << fixed << setprecision(1);

	double gradeAverage {};
	char again {};

	do {
		cout << "\nFor Lab Grades\n";
		const auto labAverage {averageGrade()};

		cout << "\nFor Test Grades\n";
		const auto testAverage {averageGrade()};

		cout << "\nFor ProjectGrades\n";
		const auto projectAverage {averageGrade()};

		gradeAverage = classAverage(labAverage, testAverage, projectAverage);

		char determineGrade {};

		getLetterGrade(gradeAverage, determineGrade);
		displayGradeReport(labAverage, testAverage, projectAverage, gradeAverage, determineGrade);

		cout << "Thanks For Stopping By!\n\n";
	} while (std::cout << "Again (y/n): " && std::cin >> again && (again == 'y' || again == 'Y'));
}

double averageGrade() {
	double gradeTotal {};
	unsigned numGrades {};

	for (double gradeAverageOption {}; gradeAverageOption != -1; ++numGrades) {
		cout << "Please Enter The Grades Please OR PRESS (-1) TO EXIT:\n";
		cin >> gradeAverageOption;
		gradeTotal += gradeAverageOption;
	}

	return (gradeTotal + 1) / (numGrades - 1);
}

double classAverage(double labAverage, double testAverage, double projectAverage) {
	return (labAverage * .5 + testAverage * .4 + projectAverage * .1);
}

void getLetterGrade(double gradeAverage, char& determineGrade) {
	if (gradeAverage >= 90)
		determineGrade = 'A';
	else if (gradeAverage >= 80)
		determineGrade = 'B';
	else if (gradeAverage >= 70)
		determineGrade = 'C';
	else if (gradeAverage >= 60)
		determineGrade = 'D';
	else
		determineGrade = 'F';
}

void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade) {
	//system("cls");
	cout << "                           *********************  Your MidTerm Grades Are  ********************\n";
	cout << "                           --------------------------------------------------------------------\n";
	cout << "*****Your Lab average Is: " << setw(9) << labAverage << "\n\n";
	cout << "****Your Test Average Is: " << setw(9) << testAverage << "\n\n";
	cout << "*Your Project Average Is: " << setw(9) << projectAverage << "\n\n";
	cout << "***Your Class Average Is: " << setw(9) << gradeAverage << setw(3) << determineGrade << "\n\n";
}

Ah, I got it figured out and made some changes thanks to you, thank you!
Topic archived. No new replies allowed.