package work3;
import java.util.Scanner;
public class chengji {
/**
* @param args
*/
public enum grade{
a(90),
b(80),
c(70),
d(60),
e(0);
private int score;
private grade(int score){
this.score=score;
}
public int getscore(){
return this.score;
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println("请输入十个数字:");
int a[]=new int [10];
int b[]=new int [5];
for(int i=0;i<10;i++){
grade g1 = new grade(a[i]);
a[i]=sc.nextInt();
if(a[i]>g1.a.getscore())
{
b[0]++;
}
else if(a[i]>g1.b.getscore())
{
b[1]++;
}
else if(a[i]>g1.c.getscore())
{
b[2]++;
}
else if(a[i]>g1.d.getscore())
{
b[3]++;
}
else{
b[4]++;
}
}
}
}怎么调用构造函数传值进去进行初始化啊,我总是出错,我用grade g1=new grade(a[i])初始化就提示不能实例化类型 chengji.grade
添加回答
举报
0/150
提交
取消