Help with Homework

Hello all, I am stuck with my homework and not sure what to do.

We are to build a program that asks the user for a class title and then a grade for that class in letter form, then asks the user if they wish to continue. They are to be able to do this as many times as they would like. When they are done entering grades for different classes, they are to be shown their overall GPA. I am stuck and not sure where my mistake is. It keeps showing the GPA as 0. Any help would be great. Thanks!

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
  #include <iostream>
#include <cmath>
#include <string>

using namespace std;


const int ArSize = 500;
int i = 0;

float totalgrade = 0;
void gradecalc();

float coursecount = 0;
string courseName[ArSize];
char response;
char coursegrade[ArSize];
float numgrade[ArSize];
int totalGPA;


int main()
{	
	cout << "Do you want to enter grades (Y or N)?\n";
	cin >> response;
	do
	{
		cout << "Enter the course name (no spaces):\n";
		cin >> courseName[i];
		cout << endl;
		cout << "Enter your grade (letters):\n";
		cin >> coursegrade[i];
		cout << endl;
		switch (coursegrade[i])
			{
			case 'a':
			case 'A' : numgrade[i] = 4;
			case 'b':
			case 'B' : numgrade[i] = 3;
			case 'c':
			case 'C' : numgrade[i] = 2;
			case 'd':
			case 'D' : numgrade[i] = 1;
			}
		i++;
		coursecount++;
		
		cout << "Do you want to enter grades?\n";
		cin >> response;
		
		} while (response != 'n' && response != 'N');		
	if (response == 'n' || 'N')
		{
			gradecalc();
			cout << "Thank you and goodbye!\n";
			return 0;
		};
	}

void gradecalc()
{
	char yesorno;
	cout << "Do you want your GPA (Y or N)?\n";
	cin >> yesorno;
	if (yesorno = 'Y' || 'y')
		{
			for(i=0;i< 5000; i++)
			{
				totalgrade += numgrade[i];
			}
			totalGPA = (totalgrade / );
			cout << "Your Grade Point Average is: " << totalGPA << ".";
			cin.get();
			cin.get();
	}
	else
		if (yesorno == 'n' || 'N')
			{cout << "Goodbye!";
		cin.get();}
		else
			{cout << "Invalid response. Do you want your GPA (Y or N)?\n";
	}
}
You need to include break; statements in your switch. Also, you should also set the number to a 4.0 if someone enters 'a'. Right now, you're only doing it for the uppercase letters.
Thanks hyperfine. I included the break; statements and added the case statements.

My issue is that the math isn't working and I don't know why. I have changed totalgrade to double from int, and numgrade and totalGPA are now double also. Honestly I am lost as to why the math isn't working. Any suggestions?
So the math still shows an enormous number and I can't figure out why. Can anyone offer some insight?
Topic archived. No new replies allowed.