//
// main.cpp
// School Book averaging Test
//
// Created by Hoekwater_Nicholas on 12/18/12.
//

#include <iostream>
using namespace std;
int main()
{
double count;
count = 1;
double average;

int A = 90, a = 90;
int B = 80, b = 80;
int C = 70, c = 70;
int D = 60, d = 60;
int F = 0, f = 0;

{
count = count + 1;
cout << " Please enter the percentage scored on each assignment(without %):\n";

{
cout << "This assignment scored an A.";}
{

cout << "This assignment scored a B."; }
{

cout << "This assignment scored a C.";
}
{

cout << "This assignment scored a D.";
}
cout << "This assignment scored an F.";
}

//Watermelon//

count++;
{

}

if(average>= 90)
{
else if(average>= 80)
{

else if(average >= 70)
{

}
else if(average >= 60)
{

}
else if(average <= 59)
}
Last edited on
 ``1234567891011121314`` ``````int A = 90, a = 90; int B = 80, b = 80; int C = 70, c = 70; int D = 60, d = 60; 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;``````

C++ doesn't work like that (actually, I don't know of any language that does). You would first need to handle the input, then, depending on what character the user entered, you would add that value to total grades. This is a tricky process and I believe you'd be better off entering the grades as a number (that's not to say that's it's impossible, however).
I believe in the "totalgrades = usergrade + totalgrades" is adding a character to an intergral. Take a look at that and I think you might know how to take it from there.
As easygoing has said the totalgrades = usergrade + totalgrades declaration is wrong. When you add a char to an int it takes the character's integers value and adds that to the int. Take a look at an ASCII chart that should help you understand what is wrong.

If you want to continue using the char input you should use either a switch statement or a ton of if else statements.

for example
case 'A':
break;
}

Last edited on
Try something like this

 ``123456789101112131415161718`` `````` for(int cnt = 0; cnt < numOf; cnt++) { cout<<"Please enter your grade: "; cin>> grade; if(toupper(grade)== 'A') total = total + 90; else if (toupper(grade)=='B') total = total + 80; else if(toupper(grade)=='C') total = total + 70; else if(toupper(grade) =='D') total = total + 60; else if(toupper(grade)=='F') total = total + 50; else {} } average = total / numOf;``````
The issue with this code is that when you declare:
`int a=10;`
you're declaring a variable "a" that is equal to 90.

But when the user enters "a", he's entering a string and not the variable you declared.
This is what I fixed. I'm still getting errors. It seems to only repeat the sequence once.
//
// main.cpp
// School Book averaging Test
//
// Created by Hoekwater_Nicholas on 12/18/12.
//

#include <iostream>
using namespace std;
int main()
{
double count;
int average = 0;
int A = 90, a = 90;
int B = 80, b = 80;
int C = 70, c = 70;
int D = 60, d = 60;
int F = 0, f = 0;

{
count = count + 1;
cout << " Please enter the percentage scored on each assignment(without %):\n";
break;
{
cout << "This assignment scored an A.";}
{

cout << "This assignment scored a B."; }
{

cout << "This assignment scored a C.";
}
{

cout << "This assignment scored a D.";
}
cout << "This assignment scored an F.";
}

//Watermelon//

count++;
{

}

if(average>= 90)
{
else if(average>= 80)
{

else if(average >= 70)
{

}
else if(average >= 60)
{