I am having some trouble with a basic program for a C++ class. In the following function, i have debugged and the arguments being passed in are correct, however the if statement below is returning 'F' for the first element of the array I pass in, and the second and each thereafter score I pass in is being returned as 'D'.
When I do the math out, my data set should hit each part of the if statement at least once, however im guessing maybe my PEMDAS is off?
Here is the if statement:
char grade(double score, double m, double s) {
if (score < (m - 1.5 * s)) {
return 'F';
}
if ((m - (1.5*s)) <= score < (m - (0.5 * s))) {
return 'D';
}
if ((m - (0.5 * s)) <= score < (m + (0.5 * s))) {
return 'C';
}
if ((m + (0.5 * s)) <= score < (m + (1.5 * s))) {
return 'B';
}
if ((m + (1.5 * s)) <= score) {
return 'A';
}
else {
return 'X';
}
}