- import java.util.Scanner;
- public class JPD05 {
-
-
- public static void main(String args[]) {
- Scanner scanner = new Scanner(System.in);
- int[] array = new int[10];
- int n=0,sum=0,temp=1;
- for(int i=0;i<array.length;i++)
- {
- System.out.print("請輸入第"+temp+"個數");
- array[i] = scanner.nextInt();
- if(array[i]>60)
- {
- n++;
- sum+=array[i];
- }
- temp++;
- }
- System.out.println("陣列中大於60的有" + n + "個\n總合為" + sum + "\n平均值為" + (sum / (double)n));
- }
- }
複製代碼 |