import java.util.Scanner;
public class JPA502 {
public static Scanner keyboard = new Scanner(System.in);
public static void main(String args[]) {
int n;
float sum=0;
System.out.print("請輸入學生人數:");
n= keyboard.nextInt();
float v[]=new float[n];
for(int i=0;i<n;i++){
System.out.print("請"+(i+1)+"個學生成績 : ");
v[i]=keyboard.nextFloat();
sum+=v[i];
}
System.out.println("人數:"+n);
System.out.println("總分:"+sum);
System.out.println("平均:"+sum/(float)n);
}
}
沒有留言:
張貼留言