Help please!! having trouble using booleans/ if statements

I have included the code I am working on. I am new to the C++ programing and I am not understanding how to use the if statements. If someone could please point me in the right direction as what I am doing wrong. I can't get my program to run. the program is suppose to output "pass" if student scores at least 50 in three test. "pass by compensation" if students scores at least 50 in two test, the lowest is at least 40. and fail if neither of the top two critierias are met. I would really appreciate your help



#include<iostream>
#include<string>
using namespace std;
const int AVERAGE_SCORE = 50;
const int NUMBER_OF_TEST = 3;




int main(void)
{
// 1. Input test scores
cout << "Enter three test scores in the range [0..100]," << endl;
cout << "seperated by spaces: ";
int score1,score2, score3;
cin >> score1 >> score2 >> score3;
cin.ignore(99,'\n');

bool wrongInput = cin.fail();
if ( wrongInput )
{
cin.clear();
cin.ignore(99,'\n');
cout << "Bad input, terminating. " << endl;
cout << "Press ENTER to finish...";
cin.ignore(99,'\n');
return 1;
}
// 2. Process

// 2.2 Calculating average scores.
int sum = score1 + score2 + score3;
int studentsGrade = sum/ NUMBER_OF_TEST;



// 2.3 Decide grade.
string grade;
if (score1 >=50 && score2 >= 50 && score3 >= 50)
{
grade = "pass";
}

if ( (studentsGrade = AVERAGE_SCORE))
for ( int count = 0; count <= 2; count ++)
if ( score1 >= 50 || score2 >= 50 || score >= 50)
else
for ( int count = 0; count <=1; count --)
if ( score1 >=40 || score2 >=50 || score >= 40)
{
grade = "Pass By Compensation";
}




if ( (studentsGrade != AVERAGE_SCORE))
if ( (score1, score2, score3 <= 50) || (score1, score2, score3 <= 40))
{
grade = "Fail";
}


// 3. Output grade
cout << grade << endl;

// 4. Shut Down
cout << "Press ENTER to finish...";
cin.ignore(99,'\n');
return 0;
}
What errors are you getting and on what lines?
OP claims not to understand how to use "if()" statements. Third sentence in post is an incomplete conditional statement. Seems legit.

Lines 44 - 48 are garbage, I don't know why they are there but delete them. You're missing a '3' and an 'else' somewhere in what is right now Line 49.
I'm getting this error message: C2181: illegal else without matching if
Where did you put the 'else'?
I've been working on my program and it still doesnt work. This is what I have so far. I got ride of the lines 44-48 and it still shows an error message about the else.






Last edited on
Topic archived. No new replies allowed.