I'm supposed to write a program that will give me the average scores for a practicum, and if the average is less than 67 then it should input the message: "You can retake practicums during the final." but it will input the other message as if it was a passing grade. I'm not sure how to fix it.
You are using = (assignment) when you should be using == (equality).
Note: To prevent this, you could make average be a const variable, by not defining it on line 11, but on line 22 instead. constfloat average = total / 3;
Then your code wouldn't compile if you tried to incorrectly re-assign average.
You also have mismatched parentheses, so your code shouldn't've compiled at all.
Also, your else if on line 29 could just be an else, since you have exhausted all other possibilities.
Don't use equality for floating point numbers. Due to the way that these are stored, the comparison may or may not succeed. Normally for floating point equality you would test that the absolute difference between the number and the value to be tested was less than a small value.
1 2
if (abs(average - 67.0) < 0.000001)
// equality code here
However, in the above the display is the same for == or >. So just:
1 2 3 4 5
if(average >= 67.0)
cout << "You have a passing practicum average." << endl;
else
cout <<"You can retake practicums during the final."<< endl;
}