package com.dream.array;
import java.util.Scanner;
//배열을 사용해 학생의 점수 총점과 평균을 출력하라.
public class ArrayEx06 {
public static void main(String[] args) {
//변수 선언
Scanner scan = new Scanner(System.in);
double total = 0, avg = 0;
int studentNum = 0;
System.out.println("학생 수를 입력하세요.");
System.out.print("입력: ");
studentNum = scan.nextInt( );
int[] score = new int[studentNum];
for(int i=0; i<studentNum; i++) {
System.out.print("점수 입력: ");
score[i] = scan.nextInt();
}
//총점을 구한다.
for(int i=0; i<score.length; i++) {
total += score[i];
}
//평균을 구한다.
avg = total / score.length;
//총점과 평균을 출력한다.
System.out.println("총점: "+total);
System.out.println("평균: "+avg);
}
}