- import java.util.Scanner;
- public class JPD05 {
- public static Scanner keyboard = new Scanner(System.in);
-
- public static void main(String args[]) {
- System.out.print("請輸入學生人數:");
-
- float sum=0;
- int num = keyboard.nextInt();
- float score [] = new float[num];
- for(int i=0;i<score.length;i++)
- {
- System.out.println("第"+(i+1)+"的學生成績");
- score[i]=keyboard.nextFloat();
- sum+=score[i];
- }
- System.out.println("人數"+score.length);
- System.out.println("總分"+sum);
- System.out.println("平均"+sum/score.length);
-
-
- }
- }
複製代碼 |