-2

My code is supposed to take in a number, and return either the letter grade or "Grade is not valid" but the else statement is not working.

#include<iostream>

using namespace std;

int main(){
    int score = 0;
    string response  = "Grade is ";
    cout<<"Please enter score: "<<endl;
    cin>>score;
    if(score<100 || score>0){
        if (score>=0 && score<60)
            cout<<response<<"F"<<endl;
        if(score>=60 && score<70)
            cout<<response<<"D"<<endl;
        if(score>=70 && score<80)
            cout<<response<<"C"<<endl;
        if(score>=80 && score<90)
            cout<<response<<"B"<<endl;
        if (score>=90 && score<100)
            cout<<response<<"A"<<endl;
    }
    else
        cout<<"Not a valid score"<<endl;

}
NathanOliver
  • 171,901
  • 28
  • 288
  • 402
Sammy2000
  • 15
  • 6

1 Answers1

0

Your logic is wrong. The score should be greater than or equal to 0 AND less than or equal to 100, not OR.

fstop_22
  • 971
  • 5
  • 9