127 0 0 0 1 0 1년전 0

중3 고1 코딩 202304

생성형 인공지능(AI)인 챗GPT에게 CTL1 과제01(나이 합)의 코드를 부탁했습니다. 과제의 해결책 구상을 영어로 번역하여 질문을 했습니다. [한글 질문] " 저는 중학생입니다. 다음 의사 코드를 자바 코드로 작성해 주세요. 1. 아버지 나이 • 아버지의 나이를 입력하고 문자 변수 아버지 나이에 저장한다. • 문자 변수 아버지 나이를 연산이 가능한 수로 변환하여 정수 변수 아버지 나이에 저장한다. 2. 아들 나이 • 아들의 나이를 입력하고 문자 변수 아들 나이에 저장한다. • 문자 변수 아들 나이를 연산이 가능한 수로 변환하여 정수 변수 아들 나이에 저장한다. 3. 아버지 나이와 아들 나이를 더하여 정수 변수 나이 합에 저장한다. 4. 나이 합을 출력한다...
생성형 인공지능(AI)인 챗GPT에게 CTL1 과제01(나이 합)의 코드를 부탁했습니다.
과제의 해결책 구상을 영어로 번역하여 질문을 했습니다.

[한글 질문]
"
저는 중학생입니다.
다음 의사 코드를 자바 코드로 작성해 주세요.
1. 아버지 나이
• 아버지의 나이를 입력하고 문자 변수 아버지 나이에 저장한다.
• 문자 변수 아버지 나이를 연산이 가능한 수로 변환하여 정수 변수 아버지 나이에 저장한다.
2. 아들 나이
• 아들의 나이를 입력하고 문자 변수 아들 나이에 저장한다.
• 문자 변수 아들 나이를 연산이 가능한 수로 변환하여 정수 변수 아들 나이에 저장한다.
3. 아버지 나이와 아들 나이를 더하여 정수 변수 나이 합에 저장한다.
4. 나이 합을 출력한다.
"

[번역문]
"
I am a middle school student.
Please write the following pseudocode in java code.
1. Father's age
1.1 Enter the father's age and save the character variable to the father's age.
1.2 Convert the character variable father's age to the number of operational numbers and store it in the integer variable father's age.
2. Son's age
2.1 Enter the age of the son and store it in the age of the son of the character variable.
2.2 Convert the character variable son age to a number that can be calculated and store it in the integer variable son age.
3. Add the age of the father and the age of the son and store them in the sum of the age of the integer variable.
4. Outputs the sum of the ages.
"

[챗GPT의 답변]
"
import java.util.Scanner;

public class AgeCalculator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

// Father's age
System.out.print("Enter the father's age: ");
char fatherAgeChar = input.next().charAt(0);
int fatherAge = Character.getNumericValue(fatherAgeChar);

// Son's age
System.out.print("Enter the son's age: ");
char sonAgeChar = input.next().charAt(0);
int sonAge = Character.getNumericValue(sonAgeChar);

// Calculate the sum of ages
int sumOfAges = fatherAge + sonAge;

// Output the sum of ages
System.out.println("The sum of ages is: " + sumOfAges);
}
}
"

중3 고1 과정에서 잘 사용하지 않는 코드가 있어서 다음과 같이 수정하라고 했습니다.

"
위 코드에서 input.next().charAt 대신 input.nextLine()으로 변경하면 코드가 어떻게 변경되나요?
How does the code change if I change it to input.nextLine() instead of input.next().charAt in the code above?
"

[챗GPT의 답변]
"
import java.util.Scanner;

public class AgeCalculator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

// Father's age
System.out.print("Enter the father's age: ");
String fatherAgeStr = input.nextLine();
int fatherAge = Integer.parseInt(fatherAgeStr);

// Son's age
System.out.print("Enter the son's age: ");
String sonAgeStr = input.nextLine();
int sonAge = Integer.parseInt(sonAgeStr);

// Calculate the sum of ages
int sumOfAges = fatherAge + sonAge;

// Output the sum of ages
System.out.println("The sum of ages is: " + sumOfAges);
}
}
"

input.next().charAt 대신 input.nextLine()으로 변경되면서
Character.getNumericValue(fatherAgeChar)가 Integer.parseInt(fatherAgeStr)로 바뀌었네요.

아주 간단한 테스트이지만 많은 것을 생각하게 합니다.

사용자가 코드를 만들기 전에 해결책 구상(의사 코드)을 준비한다면 코드는 AI에 맡겨도 되는 시대가 왔습니다. 다만 코드를 전혀 모른다면 점검 및 수정은 곤란하겠네요.


이 작은 책은 컴퓨팅 사고력을 키우는 데 도움이 되는 과제를 실었습니다.
문제 파악(IPO 포함) - 문제 분해 - 해결책 구상 - 알고리즘(구조도 포함) - 구현(파이썬과 자바 코드) 순으로 과제를 해결합니다.
선수 학습의 부분과 참고 내용은 링크로 블로그에서 제공합니다.

매달 조금씩 연재하여 컴퓨팅 사고력 향상에 기여하겠습니다.

감사합니다.

이메일 : hannui@hanmail.net
블로그 : https://blog.naver.com/snlab
소스코드와 Q&A : https://cafe.naver.com/romanceeagleta
AP 컴퓨터사이언스 A 저자
IGCSE 컴퓨터사이언스 파이썬 저자
IGCSE 컴퓨터사이언스 자바 저자
중3 고1 컴퓨팅 사고력 파이썬 저자
중3 고1 컴퓨팅 사고력 자바 저자
전 남서울대 컴퓨터학과 겸임교수.
전 경원대, 을지대 외래교수.
전 한국 정보 기술원 교육과장/소프트웨어공학 과장

㈜유페이퍼 대표 이병훈 | 316-86-00520 | 통신판매 2017-서울강남-00994 서울 강남구 학동로2길19, 2층 (논현동,세일빌딩) 02-577-6002 help@upaper.net 개인정보책임 : 이선희