본문 바로가기

카테고리 없음

연습할 프로그래밍1

반응형

[필수 정보 입력]

1. 이름: 

홍길동

2. 주민번호 앞 6자리: 

123456

3. 전화번호: 

010-123-1234


[입력된 내용]

1. 이름: 홍길동

2. 주민번호 앞 6자리: 123456

3. 전화번호: 010-123-1234




정답

import java.util.Scanner;

public class Testproject {

public static void main (String [] args) {

Scanner scanner = new Scanner(System.in);

System.out.println("[필수 정보 입력]");

System.out.println("1. 이름: ");

String name = scanner.nextLine();

System.out.println("2. 주민번호 앞 6자리: ");

String ssn = scanner.nextLine();

System.out.println("3. 전화번호: ");

String tel = scanner.nextLine();

System.out.println();

System.out.println("[입력된 내용]");

System.out.println("1. 이름: " + name);

System.out.println("2. 주민번호 앞 6자리: " + ssn);

System.out.println("3. 전화번호: " +tel);

}

}



반응형