Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved: Practice 3~4 #15

Merged
merged 14 commits into from
Jul 12, 2023
Merged

Solved: Practice 3~4 #15

merged 14 commits into from
Jul 12, 2023

Conversation

stopmin
Copy link
Collaborator

@stopmin stopmin commented Jul 7, 2023

  • 다 풀어서 기쁩니다.

@stopmin stopmin added the gpt review gpt 리뷰 요청 label Jul 7, 2023
@stopmin stopmin closed this Jul 7, 2023
@stopmin stopmin reopened this Jul 7, 2023
@stopmin stopmin added the problem 문제 풀이 label Jul 8, 2023
@shkisme shkisme merged commit 3aed2de into main Jul 12, 2023
1 check failed
@shkisme shkisme deleted the practice01-stopmin branch July 12, 2023 10:03
@@ -9,6 +9,7 @@ public static void main(String[] args) {
String personNumber = "881120-1068234";

// TODO: 주민등록번호를 연월일(YYYYMMDD) 부분과 그 뒤의 숫자 부분으로 나누어 출력하기
System.out.println(personNumber.substring(0, 6) + "\n" + personNumber.substring(8, 14));
System.out.println(personNumber.substring(0, 5));
System.out.println(personNumber.substring(7, 13));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드 패치에는 주민등록번호를 처리하는 부분이 포함되어 있습니다. 리뷰 결과와 개선 제안을 아래에서 안내합니다:

  1. substring()을 사용하여 주민등록번호를 원하는 형식으로 분리하는 점은 효과적입니다.

  2. 그러나 코드 패치에는 오류가 있습니다. personNumber.substring(8, 14) 라인에서 인덱스 범위가 잘못되었습니다. 주민등록번호의 뒷자리 숫자는 인덱스 6부터 시작하는데, 해당 값을 출력하기 위해 personNumber.substring(8, 14) 대신에 personNumber.substring(7)을 사용해야 합니다.

개선된 코드 프래그먼트는 다음과 같습니다:

System.out.println(personNumber.substring(0, 6) + "\n" + personNumber.substring(7));
System.out.println(personNumber.substring(0, 5));
System.out.println(personNumber.substring(7, 13));
  1. 추가 개선 사항은 코드에 존재하지 않습니다. 주어진 작업을 수행하기에 충분히 간단하고 명확한 방법을 사용하고 있습니다.

이제 주어진 주민등록번호를 연월일과 뒷자리 숫자로 올바르게 나눈 후 출력할 수 있습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gpt review gpt 리뷰 요청 problem 문제 풀이
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants