Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/JPA05.java
Last active May 24, 2017

Embed
What would you like to do?
TQC+ JAVA
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));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.