본문 바로가기

Algorithm/Language Coder

Jungol (Java) - 613 : 구조체 - 자가진단1

문제

"이름", "학교명", "학년"을 입력받아 아래와 같이 출력하는 프로그램을 작성하시오.

(이름과 학교명은 각각 20자 이하이다.)

 

입력 예

Songjunhyuk Beolmal 6

 

출력 예

Name : Songjunhyuk

School : Beolmal

Grade : 6

 

import java.util.*;

class School {
    String name;
    String schoolName;
    int grade;
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        School s = new School();
        s.name = sc.next();
        s.schoolName = sc.next();
        s.grade = sc.nextInt();

        System.out.println("Name : " + s.name);
        System.out.println("School : " + s.schoolName);
        System.out.println("Grade : " + s.grade);
    }
}