我有一个,如果elseif的语句来根据病情查马克和品位的标志。
I have an if elseif statement to check marks and grade the marks according to the condition.
int marks;
string grade;
if (marks>=80 && marks!>100)
{
grade = "A1";
}
else if (marks>=70 && marks!>79)
{
grade = "A2";
}
等等.....
and so on.....
,当我编译它,我得到了
however, when i compile it i got
运营商'和;&功放;不能应用于类型为布尔和INT
Operator '&&' cannot be applied to operand of type 'bool' and 'int'
帮我解决提前it.thanks。
help me fix it.thanks in advance.
其他答案使人们知道,主要的问题是,>!
不是一个运营商
Other answers have made it known that the main problem is that !>
isn't an operator.
我想建议,既然你要测试是否标记
在于你采取额外的进一步的步骤特定范围内来格式化你的条件的前pressions使用以下方式:
I'd like to suggest that since you're testing whether marks
lies within particular ranges that you take an additional further step to format your conditional expressions to use the following pattern:
if (80 <= marks && marks <= 100)
{
grade = "A1";
}
else if (70 <= marks && marks <= 79)
{
grade = "A2";
}
这是一个简单的,也许微妙的变化,但我认为它使范围检查的意图更加清晰。
It's a simple and maybe subtle change, but I think it makes the range check intent much more clear.