我真的很挣扎我不知道如何修复for
循环,这样如果用户输入的是负数,它会显示在范围内输入了多少标记,我也已经取出一些细节,例如扫描仪因为代码太多了
System.out.println("Enter mark, or -1 to finish: ");
while (mark >= 0) //process data until sentinnel is entered
{
mark = (int) input.nextInt();
System.out.println("Enter another mark, or enter -1 to exit");
if (mark >= 0)
{
sum = sum + mark;
count++;
if ((mark >= 0) && (mark <= 29)) {
cat1++;
} else if ((mark >= 30) && (mark <= 39)) {
cat2++;
} else if ((mark >= 40) && (mark <= 69)) {
cat3++;
} else if ((mark >= 70) && (mark <= 100)) {
cat4++;
} else {
System.out.println("Invalid");
}
}//end if
}//end while
System.out.println("0 - 29 ");
for (int i = 0; i <= cat1; i++) {
for (i = 0; i <= cat1; i++)
{
System.out.print("*");
}
答案 0 :(得分:0)
我认为这就是你要问的问题:
needsUpdate