I'm trying to write a basic program for a C++ lab for class, and running into some trouble.
Senario is that the program averages grades. A user enters the number of grades, then enteres a letter grade, then the program runs for however many grades the user has, then averages them all together and outputs a GPA. Here's what i have so far:
Thanks in advance... and sorry if its bad code... i'm in a 100 level class, for IT security.. programming is not my strongpoint...
#include <iostream>
using namespace std;
int main()
{
char usergrade;
int totalgrades = 0;
int numgrade = 1;
int count = 0;
int average = 0;
int A = 4, a = 4;
int B = 3, b = 3;
int C = 2, c = 2;
int D = 1, d = 1;
int F = 0, f = 0;
cout << " Please enter the number of grades to average:\n";
cin >> numgrade;
while (count < numgrade)
{
cout << " Please enter grade in letter format:\n";
cin >> usergrade;
cout << " You entered " << usergrade << ".\n";
totalgrades = usergrade + totalgrades;
count++;
}
average = totalgrades / numgrade;
cout << " Your GPA is: " << average << ".\n";
}
Hopefully you'll see my mistake.. I think what i need to do is find a way to assign the numerical value when the user enters the letter grade.
Any help would be awesome! Thanks in advance!