import java.util.*;
* @author young
*
*/
public class He {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String reg="^[0-9]+$" ;
float[] s = new float[5];
int count = 0;
float avg = 0, sum = 0;
System.out.println("輸入5個分數,以非數字結束:");
while(true){
String f = sc.nextLine();
if(f.matches(reg)){
s[count] = Integer.parseInt(f);
}else {
break;
}
count ++;
for(int j=0;j<s.length;j++){
sum+=s[j];
avg=sum/s.length;
System.out.println("平均分是:" + avg);
System.out.print("大於平均分的分數是: ");
for(float temp : s){
if(temp > avg){
System.out.print(" " + temp);
import java.util.*;
* @author young
*
*/
public class He {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String reg="^[0-9]+$" ;
float[] s = new float[5];
int count = 0;
float avg = 0, sum = 0;
System.out.println("輸入5個分數,以非數字結束:");
while(true){
String f = sc.nextLine();
if(f.matches(reg)){
s[count] = Integer.parseInt(f);
}else {
break;
}
count ++;
}
for(int j=0;j<s.length;j++){
sum+=s[j];
avg=sum/s.length;
}
System.out.println("平均分是:" + avg);
System.out.print("大於平均分的分數是: ");
for(float temp : s){
if(temp > avg){
System.out.print(" " + temp);
}
}
}
}