编写代码,使用switch语句完成对100以内,尾数为7的数字是否合格的判定,要求注释包括:break在swith语句中的功能,功能上实现case的合并,使用default语句完成对初次使用者的数值设置帮助
你想要这样?
public class ElevenTest {
public static void main(String[] args) {
int i = 0;
while(i <= 100){
switch (i % 10){
case 0 :
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 8 :
case 9 :
System.out.println("个位数不是7");
break;
case 7 :
System.out.println("个位数是7");
break;
default:
break;
}
i++;
}
}
}