(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-8242763509535969", enable_page_level_ads: true }); [JAVA] 성적처리 string 형을 변환, 래퍼 클래스 :: 깜냥깜냥
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
35
36
import java.util.Scanner;
 
public class StudentScore {
    public static void main(String[] ar) {
        Scanner sc = new Scanner(System.in);
 
        String num;
        System.out.print("How many people? ");
        num = sc.next();
        String[] name = new String[Integer.valueOf(num)];
        String[][] score = new String[Integer.valueOf(num)][4];
        String[] avg = new String[Integer.valueOf(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.next();
                
            }
            score[i][3]=Integer.toString(Integer.valueOf(score[i][0])+Integer.valueOf(score[i][1])+Integer.valueOf(score[i][2]));
            avg[i]= Float.toString(Float.parseFloat(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