공부/JAVA_source
주민등록번호로 성별 판별하기 (switch문)
초초이
2016. 10. 24. 19:52
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 38 39 40 41 42 43 44 | /* * 주민등록번호 * 123456-abcdefg * a - 성별판정(1800 = 0/9, 1900 = 1/2, 2000 = 3/4) * bc - 출생시도 * 0 : 서울 * 1 : 경기 * 2 : 강원 * 3 : 인천 * 4 : 대전, 충남 * 5 : 충북 * 6 : 전남 * 7 : 전북 * 8 : 경상도 * 9 : 제주도 * de - 출생구군 * f - 읍면리 * g - 식별키 * */ import java.io.*; public class Exam_06 { public static void main(String[] ar) throws IOException{ int check; System.out.print("출생지식별숫자 입력 = "); check = System.in.read() - 48; switch(check){ case 0 : System.out.println("서울출생"); break; case 1 : System.out.println("경기도"); break; case 2 : System.out.println("강원도"); break; case 3 : System.out.println("충청북도"); break; case 4 : System.out.println("충남, 대전"); break; case 5: System.out.println("전라남도"); break; case 6: System.out.println("전라북도"); break; case 7: System.out.println("경상남도"); break; case 8: System.out.println("경상북도"); break; case 9 : System.out.println("제주도"); break; default : System.out.println("귀화"); } } } | cs |