1. ## Please help with this code, I am confused

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

```

2. 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';`

3. 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;

{
}
{
}
else
{
{
}
}
else
{
if
{
}
}
{
{
}
{
}
{
}
{
}
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

What are all the "grade1=grade1+0" lines for? They don't do anything?

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;`

4. 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 <<
return
0;}

```

5. I would suggest you learn to use arrays and properly write the code in a non-horrible way.

6. 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.

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

Popular pages Recent additions