• 11-18-2011
rjh9136
These are the instructions for the program:
Write a flowchart and a program that will accept 5 letter grades as input from a user and convert each letter grade into grade points. Total all the grade points. Output the total grade points and the grade point average.
NOTE: Use a nested if-then-else structure to convert the letter grade input into its numeric equivalent.

Is this correct so far?:
Code:

`char grade1;char grade2;char grade3;char grade4;char grade5;　//Variables`
Code:

```cout << "Enter Letter Grade #1: " << endl;cin >> grade1;cout << "Enter Letter Grade #2: " << endl;cin >> grade2;cout << "Enter Letter Grade #3: " << endl;cin >> grade3;cout << "Enter Letter Grade #4: " << endl;cin >> grade4;cout << "Enter Letter Grade #5: " << endl;cin >> grade5;if(grade1=A){grade1=4.0;grade1= grade1+0;}elseif(grade1=B){grade1=3.0grade1=grade1+0}else{if(grade1=C){grade1=2.0grade2=grade1+0}}else{if(grade1=D){grade1=1.0grade1=grade1+0}}if(grade1==F){grade1=0grade1=grade1+0if(grade2=A){grade1=4.0grade1= grade1+0}Elseif(grade2=B){grade1=3.0grade1=grade1+0}elseIf(grade2=C){grade1=2.0grade2=grade1+0}elseif(grade1=D){grade1=1.0grade1=grade1+0}if(grade1=F){grade1=0grade1=grade1+0 ```
• 11-18-2011
rags_to_riches
Please use regular code tags and font when posting your code and question.

First thing that jumps out at me is that you're trying to use = to compare. That will not work. You must use == to compare values, as = assigns the value on the right side to the variable on the left side.

Also, single characters are always in single quotes.

Code:

`char myCharVariable = 'A';`
• 11-18-2011
smokeyangel
That's really hard to read. I took a shot at reformatting it:

Code:

```cout <<         "Enter Letter Grade #1: " << endl;cin >> grade1; cout << "Enter Letter Grade #2: " << endl;cin >> grade2; cout << "Enter Letter Grade #3: " << endl;cin >> grade3; cout << "Enter Letter Grade #4: " << endl;cin >> grade4; cout << "Enter Letter Grade #5: " << endl;cin >> grade5; if(grade1=A) {         grade1=4.0;         grade1= grade1+0; } else if(grade1=B) {         grade1=3.0         grade1=grade1+0 } else {         if(grade1=C)                 {                         grade1=2.0                         grade2=grade1+0                 } } else {         if                 (grade1=D)         {                 grade1=1.0                 grade1=grade1+0         } } if(grade1==F) {                 grade1=0                 grade1=grade1+0                 if (grade2=A)                 {                         grade1=4.0                         grade1=                         grade1+0                 }                 else if(grade2=B)                 {                         grade1=3.0                         grade1=grade1+0                 }                 else if(grade2=C)                 {                         grade1=2.0                         grade2=grade1+0                 }                 else if (grade1=D)                 {                         grade1=1.0                         grade1=grade1+0                 }                 if(grade1=F)                 {grade1=0grade1=grade1+0```
You can use "char" for the grade letters (char is "character") but not for floating point numbers. For this you can use floats:
Code:

```char grade1;char grade2;char grade3;char grade4;char grade5; //letter variables float grade1num, grade2num, grade3num, grade4num, grade5num; //decimal variables```

Then use your "if" statements to set up these float variables for each grade. Think of it in words: how do you figure out what number to give to a letter grade?

Code:

```If it an A   set num to 5.0 else if it is a B   set num to 4.0 else if it is a C   set num to 3.0 .... etc, for each of the 5 grades```
Towards the end it looks like you're trying to start summing the grades, or work out the average or something. I would recommend getting all the letters read in and converted to numbers before doing that. It'll be really simple then, just like:

Code:

`float gradesum = grade1num + grade2num + grade3num + grade4num + grade5num;`
• 11-20-2011
rjh9136
Code:

``` char```
Code:

` grade1;char grade2;char grade3;char grade4;char grade5; `

Code:

```float grade1num;float grade2num;float grade3num;float grade4num;float grade5num;float gradesum;　 cout << "Enter Letter Grade #1: " << endl;cin >> grade1;cout << "Enter Letter Grade #2: " << endl;cin >> grade2;cout << "Enter Letter Grade #3: " << endl;cin >> grade3;cout << "Enter Letter Grade #4: " << endl;cin >> grade4;cout << "Enter Letter Grade #5: " << endl;cin >> grade5;　if (grade1 == 'A'){grade1num = 4.0;}else {if (grade2 == 'B') {grade2num = 3.0;}else {if (grade3 == 'C'){grade3num = 2.0;}else {if (grade4 == 'D'){grade4num = 2.0;}else {if (grade5 == 'F'){grade5num = 0;}else {cout << "Invalid grade" << endl;}}}}}gradesum = grade1num + grade2num + grade3num + grade4num + grade5num;cout << "The sum of the GPA's is: "<< gradesum << endl;cout << "The total GPA is :" << gradesum/5;　　　 return 0;} ```
• 11-20-2011
Elysia
I would suggest you learn to use arrays and properly write the code in a non-horrible way.
• 11-20-2011
King Mir
Try to compile it, and read the error messages you get. Keep fixing it until there are no warning or error left.

Also, since you want others to look at your code, you should follow regular coding style conventions, like one ; per line.
• 11-20-2011
iMalc
Code:

```|    ^      |          ^ |    |      |          | v    |      v          | what feel    like      kind you    formatting possible? of  that    code      way game playing in        annoying are  you    the        most```