새소식

인기 검색어

비트교육_단기과정

한 사람 성적처리 프로그램 : 마기창

  • -

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
37
 
 
//  한 사람의 성적처리 프로그램
//  입력 : 이름, 국어, 영어, 수학
//  연산 : 총점, 평균
//  출력 : 이름, 국어, 영어, 수학, 총점, 평균
 
    public static void main(String[] args) {
        String name; // 이름
        int[] score; // kor,eng,mat,total
        float avg = 0;
        String[] Subject_name = { "국어""영어""수학""총점" };
        score = new int[Subject_name.length];
        Scanner sc = new Scanner(System.in);
 
        // 입력
        System.out.print("이름을 입력하시오 : ");
        name = sc.nextLine();
        for (int i = 0; i < score.length - 1; i++) {
            System.out.print(Subject_name[i] + "점수를 입력하시오 : ");
            score[i] = sc.nextInt();
            score[score.length - 1+= score[i];
        }
        avg = score[score.length - 1/ (score.length - 1);
        // 출력
        System.out.print("이름 : " + name);
        for (int i = 0; i < score.length; i++) {
            if (i == score.length - 1) {
                System.out.print(", " + Subject_name[i] + " : " + score[i]);
                break;
            }
            System.out.print(", " + Subject_name[i] + " : " + score[i]);
        }
        System.out.print(", 평균 : " + avg);
    }
 
 
cs

'비트교육_단기과정' 카테고리의 다른 글

3반 3명의 성적처리 프로그램  (0) 2022.06.24
3명 성적처리 프로그램  (0) 2022.06.24
while문 계산기  (0) 2022.06.23
while문 구구단 출력  (0) 2022.06.23
다중 for문 별 출력  (0) 2022.06.22
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.