Should be a quick fix

I'm using Visual Studios C++. This is a homework assignment but I am not looking for you to do it for me, just a hint or kick in the right direction. As you can see, I am almost there(I hope). The program now has no errors but does not display a grade and it is not accumulating the score values. No matter what figures I put in for scores it displays 32 as total points earned.




What I've done so far..............................

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
//Chapter 9 Homework-display total points earned and grade
//Created and revised by Brandon Turner on March 28, 2012

#include <iostream>

using namespace std;

//function prototype
char grade (int, char);

int main ()
{
	//declare variables
	int score = 0;
	int totalPoints = 0;//accumulator
	char grade = ' ';

	//get first score
	cout << "First score (-1 to stop): ";
	cin >> score;

	while (score != -1)
	{
		//update accumulator, then get another score
		totalPoints += score;
		cout << "Next score (-1 to stop): ";
		cin >> score;
	} //end while

	//call function to calculate grade
	totalPoints = grade;
	
	//display the total points and grade
	cout << "Total points earned: " << totalPoints << endl;
	cout << "Grade: " << grade << endl;

	system("pause");
	return 0;
}	//end of main function

//**********function definitions************
char grade (int totalPoints, char grade)
{
	//calculates grade
	
	if (totalPoints >= 315)
		grade = 'A';
	else if (totalPoints >= 280)
		grade = 'B';
	else if (totalPoints >= 245)
		grade = 'C';
	else if (totalPoints >= 210)
		grade = 'D';
	else
		grade = 'F';
	return grade;
        //end if
} //end of grade function[code] 



Last edited on
Topic archived. No new replies allowed.