학생수와 점수들이 순서대로 입력된다. 평균보다 넘은 학생들의 비율을 출력하시오
입력 : 7 100 95 90 80 70 60 50
정답: 57.143%
package _2;
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
int sum=0;
int count=0;
int[] score = new int[number];
for(int i=0; i<number ; i++) score[i] = sc.nextInt();
for(int i: score) {
sum+=i;
}
for( int i: score) {
if((sum/number) <i) count++;
}
System.out.print("평균을 넘는 학생들의 비율은 "+(count/(double)number) *100+" 입니다");
// 소수점으로 출력하려면 나누어 지는수, 나누는 수 둘중 하나는 실수형으로 캐스팅 해야한다.!!
}
}