Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class JPA05 {
- public static void main(String args[]) {
- Scanner input = new Scanner(System.in);
- int sum = 0, n = 0, num;
- System.out.println("請輸入10個整數:");
- int []arr = new int[10];
- for(int index=1;index<=10;index++) {
- System.out.print("第" + index + " 個整數:");
- num = input.nextInt();
- arr[index-1] = num;
- }
- for(int index=0;index<arr.length;index++) {
- if(arr[index] > 60) {
- n++;
- sum += arr[index];
- }
- }
- System.out.println("陣列中大於60的有" + n + "個\n總合為" + sum + "\n平均值為" + (sum / (double)n));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement