当我传递某个浮点值以与我的条件语句进行比较时,它总是执行 else 部分。
有一些带值的变量:
float total = 74.67 ;
String grade = "", point = "";
有了这个值,我想这样做:
if(total>=80){
grade = "A+";
point = "4.00";
}else if(total<=79 && total>=75){
grade = "A";
point = "3.75";
}else if(total>=70 && total<=74) {
grade = "A-";
point = "3.50";
}else if(total<=65 && total>=69){
grade = "B+";
point = "3.25";
}else if(total<=64 && total>=60){
grade = "B";
point = "3.00";
}else if (total<=59 && total>=55){
grade = "B-";
point = "2.75";
}else if (total<=54 && total>=50){
grade = "C+";
point = "2.50";
}else if(total<=49 && total>=45){
grade = "C";
point = "2.25";
}else if (total<=44 && total>=40){
grade = "D";
point = "2.00";
}else {
grade = "F";
point = "0.00";
}
但它总是显示等级=“F”和点=“0.00”。
如果我写这个,
if(total>=70 && total<=74) {
grade = "A-";
point = "3.50";
}
它显示等级=""和点=""。
总的值显示得很好,但是成绩和分数有问题。谁能告诉我有什么问题?