(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-8242763509535969", enable_page_level_ads: true }); [JAVA] 성적 처리-동적할당 :: 깜냥깜냥
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]);
        }
    }
}
 


+ Recent posts