我的 Eclipse 在使用此代码 (cpu 100% ) 后崩溃,任何人都可以确认代码是否有效。我不知道是否因为代码错误而崩溃
这是下面的代码
import java.util.Scanner;
public class ClassStudent {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int A=0;
int F=0;
int total=0;
int counter=0;
double Av12;
int pass=0;
int fail=0;
int grade;
System.out.println("enter grades or enter -1 to exit : ");
grade=input.nextInt();
while(grade>=0) {
if (grade>90 && grade<=100) {
A++;
pass++;
}
if (grade>0 && grade<=59) {
F++;
fail++;
}
total=total+grade;
counter++;
}
System.out.println("the total is "+total);
Av12=(double)total/counter;
System.out.printf("the averge is %.2f %n ",Av12);
System.out.printf("num of A is %d %n and F is %d%n and fail is %d%n and pass is %d%n ",A,F,fail,pass);
}
}
qq_花开花谢_0
qq_笑_17
相关分类