早教吧 育儿知识 作业答案 考试题库 百科 知识分享

javaprogram:giveonegradesuchas76theprogramshouldprintouttheresult"yourgradeisC"楼上的很多条件都多余了……比如if(score>=80&&score<90){System.out.println("yourgradeisB");}既然能走到这里score肯定是

题目详情
java program:give one grade such as 76 the program should print out the result " your grade is C"
楼上的很多条件都多余了……比如
if (score >= 80 && score < 90) {
System.out.println("your grade is B");
}
既然能走到这里score肯定是小于90的,所以应该是这样才对……
public void static main(String[] args) {
int score=90;
if (score >= 90) {
System.out.println("your grade is A");
} else if (score >= 80) {
System.out.println("your grade is B");
} else if (score >= 70) {
System.out.println("your grade is C");
} else if (score >= 60 ) {
System.out.println("your grade is D");
} else if (score < 60) {
System.out.println("your grade is E ,you failed");
}
}
so like you said if the condition all satisfied by above then the last conditon should be
else {
System.out.println("your grade is E,you failed.")
}
because the above conditions have been checked?
▼优质解答
答案和解析
楼上的很多条件都多余了……比如
if (score >= 80 && score < 90) {
System.out.println("your grade is B");
}
既然能走到这里score肯定是小于90的,所以应该是这样才对……
public void static main(String[] args) {
int score=90;
if (score >= 90) {
System.out.println("your grade is A");
} else if (score >= 80) {
System.out.println("your grade is B");
} else if (score >= 70) {
System.out.println("your grade is C");
} else if (score >= 60 ) {
System.out.println("your grade is D");
} else if (score < 60) {
System.out.println("your grade is E ,you failed");
}
}
看了 javaprogram:gi...的网友还看了以下:

某旅游点有一家招待所,有客房两层,已知底楼客房比二楼少一间,各个房间住的人数与这层楼的房间数相同.  2020-06-03 …

随机4个数,最少比几次,怎么比,可以将4个数从小到大正确排列.1楼的回答不完全。我不光要知道比几次  2020-07-16 …

某旅馆的底层的客房比二楼的客房少一间,一个36人的旅游团入住这家旅馆,(见问题补充补充)某旅馆的底  2020-08-04 …

已知一幢大楼高30米,某同学在距大楼500米处观察大楼,由于前面有障碍物遮挡,他站到一米高的凳子上,  2020-11-17 …

某旅游点有一家招待所,有客房两层,已知底楼客房比二楼少1间,各个房间住的人数与这层楼的房间数相同,现  2020-11-27 …

这儿有一个数学题想要麻烦大家某旅游点有一家招待所,有客房两层,已知底楼客房比二楼少1间,各个房间住的  2020-11-27 …

某旅游点有一家招待所,有客房两层,已知底楼客房比二楼少一间,各个房间住的人数与这层楼的房间数相同,现  2020-11-27 …

一道数学题、某旅游点有一家招待所,有客房两层,已知底楼客房比二楼少1间,各个房间住的人数与这层楼的房  2020-11-27 …

一道八年级数学题:某一个小旅馆的底楼客房比二楼客房少一间,各房间位的人数同这层楼的房间数相同,现有3  2020-12-04 …

1、某一个小旅馆的底楼客房比二楼客房少一间,各房间位的人数同这层楼的房间数相同,现有36位旅客,底楼  2020-12-10 …