1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import java.util.Scanner; public class StudentScore { public static void main(String[] ar) { Scanner sc = new Scanner(System.in); int num; System.out.print("Number Input: "); num = sc.nextInt(); String[] name = new String[num]; int[][] score = new int[num][4]; double[] avg = new double[num]; for (int i = 0; i < score.length; i++) { System.out.print("Name Input: "); name[i] = sc.next(); for (int j = 0; j < score[i].length - 1; j++) { System.out.print("Score Input: "); score[i][j] = sc.nextInt(); score[i][3] += score[i][j]; } avg[i] = score[i][3] / 3; } System.out.println("Name"+ "\t"+"Kor"+"\t"+"Eng"+"\t"+"Math"+"\t"+"Total"+"\t"+"Avg"); for (int i = 0; i < score.length; i++) { System.out.print(name[i] + "\t"); for (int j = 0; j < score[i].length; j++) { System.out.print(score[i][j] + "\t"); } System.out.println(avg[i]); } } } |
'code > JAVA' 카테고리의 다른 글
| [JAVA] unicasting 서로 주고 받는 채팅 (0) | 2017.04.20 |
|---|---|
| [JAVA] Stack&Queue (추상클래스, 예외처리 포함) (0) | 2017.04.20 |
| [JAVA] 성적처리 Has~a 관계 (0) | 2017.04.20 |
| [JAVA] 성적처리 string 형을 변환, 래퍼 클래스 (0) | 2017.04.20 |
| [JAVA] 사칙연산계산기 (0) | 2017.04.20 |