Defined Functions

I'm stuck. I don't know if I'm suppose to make multiple parameters for the attendance.


Note that there are/will be 23 assignment grades. Also remember that 90% attendance equals 100% of the grade. Also, 85% of the textbook completion equals 100% of the grade. You must use your function getLabGrades and also write and use a function called getAssignmentGrades. You will call getAssignmentGrades like you did getLabGrades:
double assignments = getAssignmentGrades();

Sample output:

Please enter your textbook completion percentage: 85
Please enter your attendance + misc percentage: 90
Please enter grade for assignment 1: 100
Please enter grade for assignment 2: 100
Please enter grade for assignment 3: 100
Please enter grade for assignment 4: 100
Please enter grade for assignment 5: 100
Please enter grade for assignment 6: 100
Please enter grade for assignment 7: 100
Please enter grade for assignment 8: 100
Please enter grade for assignment 9: 100
Please enter grade for assignment 10: 100
Please enter grade for assignment 11: 100
Please enter grade for assignment 12: 100
Please enter grade for assignment 13: 100
Please enter grade for assignment 14: 100
Please enter grade for assignment 15: 100
Please enter grade for assignment 16: 100
Please enter grade for assignment 17: 100
Please enter grade for assignment 18: 100
Please enter grade for assignment 19: 100
Please enter grade for assignment 20: 100
Please enter grade for assignment 21: 100
Please enter grade for assignment 22: 100
Please enter grade for assignment 23: 100
Assignment grade: 100
Please best enter grade for lab 1: 100
Please best enter grade for lab 2: 100
Please best enter grade for lab 3: 100
Please best enter grade for lab 4: 100
Please best enter grade for lab 5: 100
Lab grade: 600
Please enter your final exam percentage (guess if you like): 100
TEXTBOOK: 100
ATTENDANCE: 100
ASSIGNMENTS: 100
LABS: 600
FINAL: 100
Your final grade is 100%.

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
  #include <iostream>
#include <string>
#include <time.h>
using namespace std;

double getAssignmentGrades()
{
	double assignments = getAssignmentGrades();

double getLabGrades()
{
	double total = 0, currentgrade = 0;
	int counter = 0;
	const int numlabs = 5;

	while (counter < numlabs)
	{
		cout << "Please enter best grade for lab " << counter + 1 << ": ";
		std::cin >> currentgrade;

		if (currentgrade > 120 || currentgrade < 0)
		{
			while (currentgrade < 0 || currentgrade>120)
			{
				std::cout << "Invalid score, enter correct grade for lab " << counter + 1 << " : ";
				std::cin >> currentgrade;
			}
		}
		total += currentgrade;
		++counter;
	}

	return total;
}

int main()
{
	double labs = getLabGrades();
	cout << "Lab grade: " << labs << endl;
	cout << "Please enter your final exam percentage (guess if you like): ";
	cin >> currentgrade;
	system("pause");
	return 0;
}
Uh... your getAssignmentGrades() function is probably supposed to be a carbon copy of getLabGrades(), except replace const int numlabs = 5; with const int numlabs = 23;. It would also probably be a good idea to replace mentions of "lab" with "assignment".
Topic archived. No new replies allowed.