Algorithm/JUNGOL
[정올] 613 : 구조체 - 자가진단1
Gyuri
2022. 1. 9. 22:51
문제
"이름", "학교명", "학년"을 입력받아 아래와 같이 출력하는 프로그램을 작성하시오.
(이름과 학교명은 각각 20자 이하이다.)
입력 예
Songjunhyuk Beolmal 6
출력 예
Name : Songjunhyuk
School : Beolmal
Grade : 6
코드
import java.util.*;
class School {
String name;
String school;
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.school = sc.next();
s.grade = sc.nextInt();
System.out.println("Name : " + s.name);
System.out.println("School : " + s.school);
System.out.println("Grade : " + s.grade);
}
}