import java.io.*;
public class tongji {
public static void main(String[] args) //throws IOException
{
String str1,str2,str3,str4,str5;
int x=0,z=0,i=0,y=0;
int a[]=new int[5];
BufferedReader buf;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("输入成绩:");
str1=buf.readLine();
a[0]=Integer.parseInt(str1);
System.out.print("输入成绩:");
str2=buf.readLine();
a[1]=Integer.parseInt(str2);
System.out.print("输入成绩:");
str3=buf.readLine();
a[2]=Integer.parseInt(str3);
System.out.print("输入成绩:");
str4=buf.readLine();
a[3]=Integer.parseInt(str4);
System.out.print("输入成绩:");
str5=buf.readLine();
a[4]=Integer.parseInt(str5);
do
{
if (a[i]<0 || a[i]>100)
//JOptionPane.showMessageDialog(null, "shurucuowu!");
System.out.print("输入错误!");
if (a[i]>=0 && a[i]<60)
x=x+1;
if (a[i]>=60 && a[i]<=75)
y=y+1;
if (a[i]>75 && a[i]<=100)
z=z+1;
i++;
}while(i<5);
System.out.println("A="+z);
System.out.println("B="+y);
System.out.println("C="+x);
}
}
可以正常运行。但是下面的就不运行
import java.io.*;
public class tongji {
public static void main(String[] args) //throws IOException
{
String str1,str2,str3,str4,str5;
int x=0,z=0,i=0,y=0;
int a[]=new int[5];
BufferedReader buf;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("输入成绩:");
str1=buf.readLine();
a[0]=Integer.parseInt(str1);
System.out.print("输入成绩:");
str2=buf.readLine();
a[1]=Integer.parseInt(str2);
System.out.print("输入成绩:");
str3=buf.readLine();
a[2]=Integer.parseInt(str3);
System.out.print("输入成绩:");
str4=buf.readLine();
a[3]=Integer.parseInt(str4);
System.out.print("输入成绩:");
str5=buf.readLine();
a[4]=Integer.parseInt(str5);
while(i<5)
{
if (a[i]<0 || a[i]>100)
System.out.print("输入错误!");
if (a[i]<60)
x=x+1;
if (a[i]>=60 && a[i]<=75)
y=y+1;
if (a[i]>75)
z=z+1;
i++;
}
System.out.println("A="+z);
System.out.println("B="+y);
System.out.println("C="+x);
}
}