这是一个有效的表达吗?如果是这样,你能改写它以使它更有意义吗?例如,它是一样的(4 > y && y > 1)吗?您如何评估链式逻辑运算符?
c++ conditional boolean-logic if-statement logical-operators
这是我正在进行的任务:
编写一个程序,提示用户输入课程所获得的分数并确定分数.该程序应显示成绩的成绩和消息字符串.使用'if else'语句确定要打印消息字符串的等级和switch语句.
我编写了代码并且执行时没有任何调试错误.问题是,无论我输入什么作为我PointsEarned,我只得到F的输出!例如,如果我输入"90":
Try Harder Next Time.
GRADE: F
Run Code Online (Sandbox Code Playgroud)
有什么问题?我把我的switch语句放在错误的地方吗?这是代码:
#include <iostream>
using namespace std;
int main()
{
int PointsEarned;
char Grade;
cout << "Please input the points earned in the course: ";
cin >> PointsEarned;
if (0 <= PointsEarned < 60) {
Grade = 'F';
}
else if (60 <= PointsEarned < 70) {
Grade = 'D';
}
else if (70 <= PointsEarned < 80) {
Grade = 'C';
}
else if (80 <= PointsEarned < …Run Code Online (Sandbox Code Playgroud)