for (int i=0;i<5;i++)
{
double scores[i]=input.nextDouble();
}
包也导入了,也创建了input对象,循环里的这一句报错了,要手动输入成绩怎么办呢?有什么好的输入方法?
Scanner input = new Scanner(System.in); double[] scores = new double[5]; for(int i = 0;i<5 ; i++){ scores = input.nextDouble(); }
正确代码:
public static void main(String[] args)
{
System.out.println("请输入五个学生成绩:");
Scanner input=new Scanner(System.in);
double []scores=new double[5];
for (int i=0;i<5;i++)
{
scores[i]=input.nextDouble();
}
System.out.println("学生成绩打印为:");
System.out.println(Arrays.toString(scores));
}