problem with a nested if using some logical operators

I am getting a very minor error in my program, hopefully someone will be able to fix this easily (I am definitely a beginner): I need my program to output grades for an average of four program scores, three test scores, a course average, and a letter grade for the course. Here is the grading scale for the letter grade:

>=90 :A
80-89:B (HOWEVER, if any of the test scores is >=95, the letter grade is a A-)
70-79:C (HOWEVER, if any of the test scores is >=95, the letter grade is a B-)
<70:F

My program works fine, all the letter grades output correctly except for ONE: when it is supposed to output a B-, it INSTEAD OUTPUTS AN A-. Here is the code, I assume that is an the issue with the nested if:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int main (){
    system ("color f0");

 //Do while loop for another student
    char anotherStudent;    
    do
    {
    
    //declarations
    string fName,lName,lGrade;
    char mInitial;
    float FstPscore,SndPscore,TrdPscore,FrthPscore;
    float FstTscore,SndTscore,TrdTscore;
    float pAverage,tAverage,cAverage;
    
    //Program Input
    cout<<"Student Grade Calculator"<<endl;
    cout<<endl;
    cout<<"Please enter your first name, middle initial, and last name: "<<endl;
    cin>>fName>>mInitial>>lName;
    cout<<endl;
    cout<<"Thank you, your name is "<<fName<<" "<<mInitial<<" "<<lName<<endl;
    cout<<endl;
    cout<<"Please enter the first program score <0-100>: ";
    cin>>FstPscore;
    cout<<endl;
    cout<<"You entered "<<FstPscore<<endl;
    cout<<endl;
    cout<<"Please enter the second program score <0-100>: ";
    cin>>SndPscore;
    cout<<endl;
    cout<<"You entered "<<SndPscore<<endl;
    cout<<endl;
    cout<<"Please enter the third program score <0-100>: ";
    cin>>TrdPscore;
    cout<<endl;
    cout<<"You entered "<<TrdPscore<<endl;
    cout<<endl;
    cout<<"Please enter the fourth program score <0-100>: ";
    cin>>FrthPscore;
    cout<<endl;
    cout<<"You entered "<<FrthPscore<<endl;
    cout<<endl;
    cout<<"Please enter the first test score <0-100>: ";
    cin>>FstTscore;
    cout<<endl;
    cout<<"You entered "<<FstTscore<<endl;
    cout<<endl;
    cout<<"Please enter the second test score <0-100>: ";
    cin>>SndTscore;
    cout<<endl;
    cout<<"You entered "<<SndTscore<<endl;
    cout<<endl;
    cout<<"Please enter the third test score <0-100>: ";
    cin>>TrdTscore;
    cout<<endl;
    cout<<"You entered "<<TrdTscore<<endl;
    cout<<endl;
    
    //Average Calculations
    pAverage=(FstPscore+SndPscore+TrdPscore+FrthPscore)/4;
    tAverage=(FstTscore+SndTscore+TrdTscore)/3;
    cAverage=(pAverage+tAverage)/2;
 
    //Nested If
    if (cAverage>=90) {lGrade = "A";}                                                    
    else if (cAverage>=80&&FstTscore>=95||SndTscore>=95||TrdTscore>=95) {lGrade = "A-";} 
    else if (cAverage>=80) {lGrade = "B";}
    else if (cAverage>=70&&FstTscore>=95||SndTscore>=95||TrdTscore>=95) {lGrade = "B-";}                                              
    else if (cAverage>=70) {lGrade = "C";}
    else {lGrade = "F";}                          
    
    //Program Output 
    cout<<"123456789012345678901234567890123456789012345"<<endl;//45 spaces 
    cout<<setfill('*');
    cout<<setw(45)<<"*"<<endl;
    cout<<"Name: "<<fName<<" "<<mInitial<<" "<<lName<<endl;
    cout<<endl;
    cout<<fixed<<showpoint<<setprecision(2);
    cout<<"Program Average..........   "<<pAverage<<endl;
    cout<<endl;
    cout<<"Test Average.............   "<<tAverage<<endl;
    cout<<endl;
    cout<<"Course Average...........   "<<cAverage<<endl;
    cout<<endl;
    cout<<"Letter Grade.............   "<<lGrade<<endl;
    cout<<endl;
    cout<<setfill('*');
    cout<<setw(45)<<"*"<<endl; 
    
    //2nd part of do while loop 
    cout<<"Please enter Y for another student or N to quit:";
    cin>>anotherStudent; 
    cout<<endl;
    }while(anotherStudent=='y');
    cout<<endl;
    system ("pause");
    return 0;
}//end of main 
Topic archived. No new replies allowed.