I looked a project on this site (grading project) and it basically asks the user to input a grade, and your program will decide whether it is a A, B, C etc etc. Let me past the code first for you to see.
float usergrade = 0;
cout << "Enter your grade here: ";
cin >> usergrade;
if (usergrade = 100)
cout << "Congratulations! You have a perfect score! " << endl;
elseif (usergrade >= 90 && usergrade <= 99)
cout << "You have an A! " << endl;
elseif (usergrade >= 80 && usergrade <= 89)
cout << "You have a B! " << endl;
elseif (usergrade >= 70 && usergrade <= 79)
cout << "You have a C! " << endl;
elseif (usergrade >= 60 && usergrade <= 69)
cout << "You have a D! " << endl;
elseif (usergrade > 0 && usergrade < 60);
cout << "You have failed. " << endl;
When I run it, it gives the first statement (you have a perfect score) and the last statement (you failed) no matter the grade I input. I haven't learned else if statments properly yet, just using common sense and prior knowledge on this one.
Check line 11. You want to perform a comparison between usergrade and 100, but what you're doing is an assignment. This explains why the first line always prints.
Assignment: if (usergrade = 100)
Comparison: if (usergrade == 100)
The reason the last line is always printing is because you have a semicolon at the end of line 26. Review the syntax of 'if' statements. Even though you've indented line 27, that does not mean it falls within the scope of elseif (usergrade > 0 && usergrade < 60); You should remove the semicolon.