public class demo1 { public static void main(String[] args) { int clanum=4; int stunum=3; for(int c=1;c<=clanum;c++){ double sum=0; System.out.println("***输入第"+c+"个班级的学生分数***"); for(int s=1;s<=stunum;s++){ System.out.print("输入第"+s+"个的学生分数:"); double score=new Scanner(System.in).nextDouble(); sum=sum+score; } double avg=sum/stunum; System.out.println("平均分:"+avg); } } }
我认为float就够用就不需要double