展开全部
name,id,status怎么是static呢?改成下面的:
public class Student
{
public String name;
public int id=0;
public int status=0;
public static void main(String[] args)
{
int i=0,j=0,num=0;
Student[] student=new Student[5];
for (int a=0;a
student[a] = new Student();
}
Random rand=new Random();
Scanner cin=new Scanner(System.in);
System.out.println("********输入32313133353236313431303231363533e59b9ee7ad9431333264653532区*********");
System.out.println();
for(i=0;i<5;i++)
{
System.out.print(i+1+"请输入学生的姓名:");
student[i].name=cin.next();
student[i].id=Math.abs(rand.nextInt());
System.out.print(i+1+"该学生的学号:");
System.out.println(student[i].id);
System.out.print(i+1+"该学生所在的年级:");
student[i].status=rand.nextInt(4);
while(student[i].status==0) student[i].status=rand.nextInt(4);
System.out.println(student[i].status);
System.out.println();
}
System.out.println("********显示区*********");
System.out.println();
while(j<5)
{
if(student[j].status==3)
{
System.out.println("所有三年级学生的姓名和id是:");
System.out.println(student[j].name+" "+student[j].id);
num++;
}
j++;
}
if(num==0) System.out.print("没有三年级的学生");
}
}