From 4903754994cd1140563cd66c20b35cbb1421d322 Mon Sep 17 00:00:00 2001 From: cho-coding Date: Wed, 18 Jan 2023 21:15:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EC=A0=9C=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kimhyunho/report1/Report1_1 | 3 +++ src/kimhyunho/report1/Report1_2 | 3 +++ src/kimhyunho/report1/Report1_3.java | 19 ++++++++++++++++++ src/kimhyunho/report2/Report2_2.java | 30 ++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 src/kimhyunho/report1/Report1_1 create mode 100644 src/kimhyunho/report1/Report1_2 create mode 100644 src/kimhyunho/report1/Report1_3.java create mode 100644 src/kimhyunho/report2/Report2_2.java diff --git a/src/kimhyunho/report1/Report1_1 b/src/kimhyunho/report1/Report1_1 new file mode 100644 index 0000000..d8a3d39 --- /dev/null +++ b/src/kimhyunho/report1/Report1_1 @@ -0,0 +1,3 @@ +2-4번 문제 + +정답 : double d = 1.4e3f; diff --git a/src/kimhyunho/report1/Report1_2 b/src/kimhyunho/report1/Report1_2 new file mode 100644 index 0000000..53a90b2 --- /dev/null +++ b/src/kimhyunho/report1/Report1_2 @@ -0,0 +1,3 @@ +2-7번 번 문제 + +정답 : System.out.println(true + null); // 오류 \ No newline at end of file diff --git a/src/kimhyunho/report1/Report1_3.java b/src/kimhyunho/report1/Report1_3.java new file mode 100644 index 0000000..bca3680 --- /dev/null +++ b/src/kimhyunho/report1/Report1_3.java @@ -0,0 +1,19 @@ +package kimhyunho.report1; +// 2-8 번 문제 <- 이렇게 문제 번호 작성 필수 +public class Report1_3 { + public static void main(String[] args){ + int x = 1; + int y = 2; + int z = 3; + /* + x = 2; + y = 3; + z = 1; + */ + System.out.println("x="+x); + System.out.println("y="+y); + System.out.println("z="+z); + } +} +//예상 결과 : x=2, y=3, z=1 + diff --git a/src/kimhyunho/report2/Report2_2.java b/src/kimhyunho/report2/Report2_2.java new file mode 100644 index 0000000..3c854b9 --- /dev/null +++ b/src/kimhyunho/report2/Report2_2.java @@ -0,0 +1,30 @@ +package kimhyunho.report2; + +public class Report2_2 { + public static void main(String[] args) { + int x = 2; + int y = 5; + char c = 'A'; // 'A'의 문자코드는 65 + + System.out.println(y >= 5 || x < 0 && x > 2); + // 정답 : false // x값 미충족 + System.out.println(y += 10 - x++); + // 정답 : 15 - 2 = 13 + System.out.println(x += 2); + // 정답 : 4 + System.out.println(!('A' <= c && c <= 'Z')); + // 정답 : true // 값은 false 이지만 ! 으로 true + System.out.println('C' - c); + // 정답 : 2 + System.out.println('5' - '0'); + // 정답 : 5 + System.out.println(c + 1); + // 정답 : 66 + System.out.println(++c); + // 정답 : B + System.out.println(c++); + // 정답 : A + System.out.println(c); + // 정답 : 'A' + } +} \ No newline at end of file From ddd5fbcd8ef20b953822978fda13c0b76d7e1d88 Mon Sep 17 00:00:00 2001 From: cho-coding Date: Fri, 20 Jan 2023 15:36:25 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=A0=9C=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kimhyunho/report2/Report2_1 | 3 ++ src/kimhyunho/report2/Report2_3.java | 11 ++++++ src/kimhyunho/report2/Report2_4.java | 20 ++++++++++ src/kimhyunho/report2/Report2_5.java | 16 ++++++++ src/kimhyunho/report2/Report2_6.java | 17 ++++++++ src/kimhyunho/report3/Report3_1 | 22 +++++++++++ src/kimhyunho/report3/Report3_10.java | 44 +++++++++++++++++++++ src/kimhyunho/report3/Report3_2.java | 14 +++++++ src/kimhyunho/report3/Report3_3.java | 16 ++++++++ src/kimhyunho/report3/Report3_4.java | 27 +++++++++++++ src/kimhyunho/report3/Report3_5.java | 36 +++++++++++++++++ src/kimhyunho/report3/Report3_6.java | 15 +++++++ src/kimhyunho/report3/Report3_7.java | 21 ++++++++++ src/kimhyunho/report3/Report3_8.java | 9 +++++ src/kimhyunho/report3/Report3_9.java | 23 +++++++++++ src/kimhyunho/report3/Untitled.drawio.png | Bin 0 -> 6784 bytes src/kimhyunho/report4/Report4_1 | 3 ++ src/kimhyunho/report4/Report4_2 | 3 ++ src/kimhyunho/report4/Report4_3.java | 22 +++++++++++ src/kimhyunho/report4/Report4_4.java | 38 ++++++++++++++++++ src/kimhyunho/report4/Report4_5.java | 46 ++++++++++++++++++++++ src/kimhyunho/report4/Report4_6.java | 39 ++++++++++++++++++ 22 files changed, 445 insertions(+) create mode 100644 src/kimhyunho/report2/Report2_1 create mode 100644 src/kimhyunho/report2/Report2_3.java create mode 100644 src/kimhyunho/report2/Report2_4.java create mode 100644 src/kimhyunho/report2/Report2_5.java create mode 100644 src/kimhyunho/report2/Report2_6.java create mode 100644 src/kimhyunho/report3/Report3_1 create mode 100644 src/kimhyunho/report3/Report3_10.java create mode 100644 src/kimhyunho/report3/Report3_2.java create mode 100644 src/kimhyunho/report3/Report3_3.java create mode 100644 src/kimhyunho/report3/Report3_4.java create mode 100644 src/kimhyunho/report3/Report3_5.java create mode 100644 src/kimhyunho/report3/Report3_6.java create mode 100644 src/kimhyunho/report3/Report3_7.java create mode 100644 src/kimhyunho/report3/Report3_8.java create mode 100644 src/kimhyunho/report3/Report3_9.java create mode 100644 src/kimhyunho/report3/Untitled.drawio.png create mode 100644 src/kimhyunho/report4/Report4_1 create mode 100644 src/kimhyunho/report4/Report4_2 create mode 100644 src/kimhyunho/report4/Report4_3.java create mode 100644 src/kimhyunho/report4/Report4_4.java create mode 100644 src/kimhyunho/report4/Report4_5.java create mode 100644 src/kimhyunho/report4/Report4_6.java diff --git a/src/kimhyunho/report2/Report2_1 b/src/kimhyunho/report2/Report2_1 new file mode 100644 index 0000000..59759e7 --- /dev/null +++ b/src/kimhyunho/report2/Report2_1 @@ -0,0 +1,3 @@ +3-1번 문제 + +정답 : b = (byte)i; , ch = (char)b; diff --git a/src/kimhyunho/report2/Report2_3.java b/src/kimhyunho/report2/Report2_3.java new file mode 100644 index 0000000..343cbd8 --- /dev/null +++ b/src/kimhyunho/report2/Report2_3.java @@ -0,0 +1,11 @@ +package kimhyunho.report2; + +//3-3. 아래는 변수의 num 값 중에서 백의 자리 이하를 버리는 코드이다. +//만일 변수 num의 값이 '456'이라면 '400'이 되고, '111'이라면 '100'이 된다. +//알맞은 코드를 넣으시오. +public class Report2_3 { + public static void main(String[] args) { + int num = 456; + System.out.println((int)(num * 0.01)*100); + } +} diff --git a/src/kimhyunho/report2/Report2_4.java b/src/kimhyunho/report2/Report2_4.java new file mode 100644 index 0000000..c5d7c0f --- /dev/null +++ b/src/kimhyunho/report2/Report2_4.java @@ -0,0 +1,20 @@ +package kimhyunho.report2; + +//3-4. 아래의 코드는 사과를 담는데 필요한 바구니(버켓)의 수를 구하는 코드이다. +//만일 사과의 수가 123개이고 하나의 바구니에는 10개의 사과를 담을 수 있다면, 13개의 바구니가 필요할 것이다. +//알맞은 코드를 넣으시오. +class Report2_4 { + public static void main(String[] args){ + int numOfApples = 123; // 사과의 개수 + int sizeOfBucket = 10; // 바구니의 크기(바구니에 담을 수 있는 사과의 개수) + int numOfBucket = (numOfApples/sizeOfBucket+1); // 모든 사과를 담는데 필요한 바구니의 수 + +// int appples = 123; +// int boxSize = 10; +// System.out.println((int)Math.ceil((double)appples/boxSize)); +// + + System.out.println("필요한 바구니의 수 :"+numOfBucket); + } +} +//예상 결과 -> 필요한 바구니의 수 :13 diff --git a/src/kimhyunho/report2/Report2_5.java b/src/kimhyunho/report2/Report2_5.java new file mode 100644 index 0000000..6a472ab --- /dev/null +++ b/src/kimhyunho/report2/Report2_5.java @@ -0,0 +1,16 @@ +package kimhyunho.report2; + +//3-5. 아래는 변수 num의 값에 따라 '양수', '음수', '0'을 출력하는 코드이다. +//삼항연산자를 이용해서 빈칸에 알맞은 코드를 넣으시오. +//Hint : 삼항 연산자를 두 번 사용할 것! +class Report2_5{ + public static void main(String[] args){ + int num = 10; + String a = ""; + + if(num >=0) a = "양수"; + else a = "음수"; + System.out.println(a); + } +} +//예상 결과 : 양수 diff --git a/src/kimhyunho/report2/Report2_6.java b/src/kimhyunho/report2/Report2_6.java new file mode 100644 index 0000000..17c68e6 --- /dev/null +++ b/src/kimhyunho/report2/Report2_6.java @@ -0,0 +1,17 @@ +package kimhyunho.report2; + +//3-6. 아래는 화씨(Fahrenheit)를 섭씨(Celcius)로 변환하는 코드이다. +//변환 공식이 'C = 5/9*(F-32)'라고 할 때, 빈 칸에 알맞은 코드를 넣으시오. +// 단, 변환값은 소수점 셋째자리에서 반올림하며, Math.round() 함수를 사용하지 않고 처리할 것! +class Report2_6{ + public static void main(String[] args){ + int fahrenheit = 100; + float celcius = (int)(5/9f*(fahrenheit-32)*100)*0.01f+0.01f; + + System.out.println("Fahrenheit:"+fahrenheit); + System.out.println("Celcius:"+celcius); + } +} + + +//예상 결과 : Fahrenheit:100, Celcius:37.78 \ No newline at end of file diff --git a/src/kimhyunho/report3/Report3_1 b/src/kimhyunho/report3/Report3_1 new file mode 100644 index 0000000..3c41b12 --- /dev/null +++ b/src/kimhyunho/report3/Report3_1 @@ -0,0 +1,22 @@ +// 4-1번 문제 + +정답 : +int형 변수 x가 10보다 크고 20보다 작을 때 true인 조건식 + x > 10 && x < 20 + +char형 변수 ch가 공백이나 탭이 아닐 때 true인 조건식 + ch !='' || ch =="" +char형 변수 ch가 'x' 또는 'X'일 때 true인 조건식 + ch == "x" || ch == "X" +char형 변수 ch가 숫자('0'~'9')일 때 true인 조건식 + ch >= '0' && ch <= '9' +char형 변수 ch가 영문자(대문자 또는 소문자)일 때 true인 조건식 + ch >= 'a' && ch <= 'z' || ch => 'A' && ch <= 'Z' +int형 변수 year가 400으로 나눠떨어지거나 또는 4로 나눠떨어지고 100으로 나눠떨어지지 않을때 true인 조건식 + int year = 400 + + +boolean형 변수 powerOn이 false일 때 true인 조건식 + + +문자열 참조변수 str이 "yes"일 때 true인 조건식 diff --git a/src/kimhyunho/report3/Report3_10.java b/src/kimhyunho/report3/Report3_10.java new file mode 100644 index 0000000..c8ade24 --- /dev/null +++ b/src/kimhyunho/report3/Report3_10.java @@ -0,0 +1,44 @@ +package kimhyunho.report3; + +//4-10. 다음은 숫자맞추기 게임을 작성한 것이다. 1과 100사이의 값을 반복적으로 입력해서 +//컴퓨터가 생각한 값을 맞추면 게임이 끝난다. +//사용자가 값을 입력하면, 컴퓨터는 자신이 생각한 값과 비교해서 결과를 알려준다. +//사용자가 컴퓨터가 생각한 숫자를 맞추면 게임이 끝나고 몇 번 만에 숫자를 맞췄는지 알려준다. +class Report3_10 { + // 1~100사이의 임의의 값을 얻어서 answer에 저장한다. + int answer = (int)(Math.random() * 100 +1); + int input = 0; //사용자입력을 저장할 공간 + int count = 0; //시도횟수를 세기위한 변수 + + // 화면으로 부터 사용자입력을 받기 위해서 Scanner클래스 사용 + java.util.Scanner s = new java.util.Scanner(System.in); + do { + count++; + System.out.print("1과 100사이의 값을 입력하세요 : "); + input = s.nextInt(); //입력받은 값을 변수 input에 저장한다. + if (answer > input ) { + System.out.println("더 큰 수를 입력하세요"); + else if (answer < input) { + else { + System.out.println("맞췄습니다."); + System.out.println("시도는 "+count+"번 입니다."); + break; + } + } + } while(true); //무한반복문 +} // end of main +} // end of class +//예상 결과 +//1과 100사이의 값을 입력하세요 : 50 +//더 큰 수를 입력하세요. +//1과 100사이의 값을 입력하세요 : 75 +//더 큰 수를 입력하세요. +//1과 100사이의 값을 입력하세요 : 87 +//더 작은 수를 입력하세요. +//1과 100사이의 값을 입력하세요 : 80 +//더 작은 수를 입력하세요. +//1과 100사이의 값을 입력하세요 : 77 +//더 작은 수를 입력하세요. +//1과 100사이의 값을 입력하세요 : 76 +//맞혔습니다. +//시도횟수는 6번입니다. diff --git a/src/kimhyunho/report3/Report3_2.java b/src/kimhyunho/report3/Report3_2.java new file mode 100644 index 0000000..7d28cd7 --- /dev/null +++ b/src/kimhyunho/report3/Report3_2.java @@ -0,0 +1,14 @@ +package kimhyunho.report3; + +//4-2. 1부터 20까지의 정수중에서 2 또는 3의 배수가 아닌 수의 총합을 구하세요. +class Report3_2 { + public static void main(String[] args) { + int sum = 0; + for (int i = 1; i <= 20; i++) { + if (i % 2 == 0 || i % 3 == 0) ; + sum += i; + } + System.out.println("sum="+sum); + } +} + diff --git a/src/kimhyunho/report3/Report3_3.java b/src/kimhyunho/report3/Report3_3.java new file mode 100644 index 0000000..bd6eeaa --- /dev/null +++ b/src/kimhyunho/report3/Report3_3.java @@ -0,0 +1,16 @@ +package kimhyunho.report3; + +//4-3. 1+(1+2)+(1+2+3)+(1+2+3+4)+...+(1+2+3+...+10)의 결과를 계산하세요. +class Report3_3 { + public static void main(String[] args){ + int sum = 0; + int totalSum = 0; + + for (int i = 1; i <=10; i++) { + sum += i+(i+1); + totalSum = sum; + } + System.out.println("totalSum="+totalSum); + } +} + diff --git a/src/kimhyunho/report3/Report3_4.java b/src/kimhyunho/report3/Report3_4.java new file mode 100644 index 0000000..71055ad --- /dev/null +++ b/src/kimhyunho/report3/Report3_4.java @@ -0,0 +1,27 @@ +package kimhyunho.report3; + +//4-4. 1+(-2)+3+(-4)+...과 같은 식으로 계속 더해나갔을 때, +//몇까지 더해야 총합이 100 이상이 되는지 구하세요. +class Report3_4 { + public static void main(String[] args) { + int sum = 0; // 총합을 저장할 변수 + int s = 1; // 값의 부호를 바꿔주는데 사용할 변수 + int num = 0; + +// while (true, sum >= 100, s++, s=-s); +// num = sum * s; + + + if (num % 2 == 0) { + num = 1 * -s; + } else { + num = s; + } + sum += num; + + System.out.println("num=" + num); + System.out.println("sum=" + sum); + + } +} + diff --git a/src/kimhyunho/report3/Report3_5.java b/src/kimhyunho/report3/Report3_5.java new file mode 100644 index 0000000..a201a98 --- /dev/null +++ b/src/kimhyunho/report3/Report3_5.java @@ -0,0 +1,36 @@ +package kimhyunho.report3; + +//4-5. 다음의 for문을 while문으로 변경하세요. +class Report3_5 { + public static void main(String[] args) { + int i = 0, j = 0; + + while (i < 5) { + +// 행 열 +// i = 0 ,j = 0 +// i = 0 ,j = 1 +// i = 1 ,j = 1 +// i = 1 ,j = 2 +// i = 2 ,j = 2 +// i = 2 ,j = 3 +// i = 3 ,j = 3 +// i = 3 ,j = 4 +// i = 4 ,j = 4 +// i = 4 ,j = 5 +// i = 5 ,j = 5 + + + while (j <= i) { + System.out.print('*'); + j++; + } + + i++; + j = 0; + System.out.println(); + }//end of main + } // end of class +} + + diff --git a/src/kimhyunho/report3/Report3_6.java b/src/kimhyunho/report3/Report3_6.java new file mode 100644 index 0000000..a8f8d4d --- /dev/null +++ b/src/kimhyunho/report3/Report3_6.java @@ -0,0 +1,15 @@ +package kimhyunho.report3; + +//3-6 두 개의 주사위를 던졌을 때, 눈의 합이 6이 되는 모든 경우의 수를 출력하는 프로그램을 작성하세요. +class Report3_6 { + public static void main(String[] args) { + + for (int i = 1; i <= 6; i++) { + for (int j = 1; j <= 6; j++) { + if ((i + j) == 6) { + System.out.println(i + "+" + j + "=" + (i + j)); + } + } + } + } +} \ No newline at end of file diff --git a/src/kimhyunho/report3/Report3_7.java b/src/kimhyunho/report3/Report3_7.java new file mode 100644 index 0000000..25226ef --- /dev/null +++ b/src/kimhyunho/report3/Report3_7.java @@ -0,0 +1,21 @@ +package kimhyunho.report3; + +//4-7. 숫자로 이루어진 문자열 str이 있을 때, 각 자리의 합을 더한 결과를 출력하는 코드를 완성하세요. +//만일 문자열이 "12345"라면, ‘1+2+3+4+5’의 결과인 15를 출력이 출력되어야 합니다. +class Report3_7 { + public static void main(String[] args) { + String str = "12345"; + int sum = 0; + + for (int i = 0; i < str.length(); i++) { + for (int j = 0; j <= 5; j++) { + if (sum <= 5); + + + + } + } + + System.out.println("sum=" + sum); + } +}//예상 결과 : sum=15 \ No newline at end of file diff --git a/src/kimhyunho/report3/Report3_8.java b/src/kimhyunho/report3/Report3_8.java new file mode 100644 index 0000000..699f7f9 --- /dev/null +++ b/src/kimhyunho/report3/Report3_8.java @@ -0,0 +1,9 @@ +package kimhyunho.report3; + +//4-8. Math.random()을 이용해서 1부터 6 사이의 임의의 정수를 변수 value에 저장하는 코드를 완성하세요. +class Report3_8 { + public static void main(String[] args) { + int value = (int)(Math.random() * 6 + 1); + System.out.println("value:"+value); + } +} \ No newline at end of file diff --git a/src/kimhyunho/report3/Report3_9.java b/src/kimhyunho/report3/Report3_9.java new file mode 100644 index 0000000..90c7bdb --- /dev/null +++ b/src/kimhyunho/report3/Report3_9.java @@ -0,0 +1,23 @@ +package kimhyunho.report3; + +//4-9. int 타입의 변수 num이 있을 때, 각 자리의 합을 더한 결과를 출력하는 코드를 완성하세요. +//만일 변수 num의 값이 12345라면, ‘1+2+3+4+5’의 결과인 15를 출력하세요. +//문자열로 변환하지 말고 숫자로만 처리하세요. +class Report3_9 { + public static void main(String[] args) { + int num = 12345; + int sum = 0; + while (num > 0) { + +// 12345 $ 10 = 5 +// 1234 $ 10 = 4 +// 123 $ 10 = 3 +// 12 $ 10 = 2 +// 1 $ 10 = 1 + + sum += num%10; + num /=10; + } + System.out.println("sum="+sum); + } + } //예상 결과 : sum=15 diff --git a/src/kimhyunho/report3/Untitled.drawio.png b/src/kimhyunho/report3/Untitled.drawio.png new file mode 100644 index 0000000000000000000000000000000000000000..3964d6f5ea61143809240084572dc5463dcd553d GIT binary patch literal 6784 zcmeI1`#;m~-@qMmNT?iYj`hKiQ#;s9eS9>wVPkDp-CAfBqe95oKGPt zB*`Qc(TPG-BGE}F6^i@ax6l1}+<(CRxPQ7I+pg={>;2mGx~|vzbzSe*^I9s2=%k{g ztt2HSrQ+g@aR=%EDJf~8qCC)g(Bg^%D(OgfCkLs9A>DZ?sdb)0td}q>Hh>$-kpjaV z|Fpm`NKkmB5DdqFVK642Z^h;^0|m^mNGl#k2#A2|Vc~3U0GGr5qXUD$;Fb`mB@{`4 zBEWDo6bTg8C@TmALI0!A4CL_s?GRxF0Xi^sW3sqBVR&Q^814Xkci{;+p+F6YfpV`0 zPTY|$**PpQFeJpE%ja?f19(txYgc+KiF|+> zfyYL9U{FvBF_eU`#svw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x;`of{-`6aSw`tVBV&A~O((f-dgB+%|{hkl4} z{QBn8{IKBezND^Q(QhBuuYaF@+0EMf<>&8f8j}5rS9TuXV(H$uA*&z+GL+&+Gs|)* z{PO&4j$12S3NWT)ReqsPp?4nEK3P4bt=y1*Q{Q)=@ftWQPUZ3=zN|c^BZ?Q5s z4Mk93k)hu{!A27ZgqS&_!};)Hooa8v58c0G`Hwqp zArFsi{BAOxb*gEt*6-zt!Sk-Wb|Qz={C7QFzX~sQd@DrwW&A!yYi^i{@^ooi$W+W^Dg7v>6UZ6Ixu>HiP!IY-zY8z4jqSq lgN!Fnwu=S_PCj4TczO}na%z3eao{f{DHkje)8N2J{4Y3`@NfVC literal 0 HcmV?d00001 diff --git a/src/kimhyunho/report4/Report4_1 b/src/kimhyunho/report4/Report4_1 new file mode 100644 index 0000000..57f2469 --- /dev/null +++ b/src/kimhyunho/report4/Report4_1 @@ -0,0 +1,3 @@ +// 5-1 번 문제 + +정답 : int[] arr = {1,2,3,}; diff --git a/src/kimhyunho/report4/Report4_2 b/src/kimhyunho/report4/Report4_2 new file mode 100644 index 0000000..9f31a6b --- /dev/null +++ b/src/kimhyunho/report4/Report4_2 @@ -0,0 +1,3 @@ +// 5-2 번 문제 + +정답 : 20 diff --git a/src/kimhyunho/report4/Report4_3.java b/src/kimhyunho/report4/Report4_3.java new file mode 100644 index 0000000..505f8a7 --- /dev/null +++ b/src/kimhyunho/report4/Report4_3.java @@ -0,0 +1,22 @@ +package kimhyunho.report4; + +//5-3. 배열 arr에 담긴 모든 값을 더하는 프로그램을 완성하세요. +class Report4_3 { + public static void main(String[] args){ + int[] arr = {10, 20, 30, 40, 50}; + int sum = 0; +// arr[0] = 10 +// arr[1] = 20 +// arr[2] = 30 +// arr[3] = 40 +// arr[4] = 50 + + for (int i = 0; i question.length으로 " j " 의 반복문 작성 + // 랜덤함수 돌려야할 변수값 'idx' 생성 + // 값을 바꾸기 위한 tmp 생성 + + for (int j = 0; j ", i + 1, new String(question)); + String answer = scanner.nextLine(); + + // trim()으로 answer의 좌우 공백을 제거한 후, equals로 word[i]와 비교 + if (words[i].equals(answer.trim())) + System.out.printf("맞았습니다.%n%n"); + else + System.out.printf("틀렸습니다.%n%n"); + } + } //end of main +}//end of class