diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..c671481
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..0b0b192
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hanghae-java-study-12.iml b/hanghae-java-study-12.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/hanghae-java-study-12.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/choiwonbin/report1/Report1_1 b/src/choiwonbin/report1/Report1_1
index 3f37658..8b57915 100644
--- a/src/choiwonbin/report1/Report1_1
+++ b/src/choiwonbin/report1/Report1_1
@@ -1,3 +1,18 @@
2-4번 문제
+//2-4. 다음 중 변수를 잘못 초기화 한 것은?
+
+byte b = 256;
+char c = '';
+char answer = 'no';
+float f = 3.14
+double d = 1.4e3f;
+
+
정답 :
+byte b = 256; byte 값은 -128~127 까지
+char c = ''; char 은 하나의 문자만 저장 가능
+char answer = 'no'; char 은 하나의 문자만 저장 가능
+float f = 3.14 float는 float의 리미럴 f가 입력되지 않아 오류 발생
+
+
diff --git a/src/choiwonbin/report1/Report1_2 b/src/choiwonbin/report1/Report1_2
index f4e5811..71d806e 100644
--- a/src/choiwonbin/report1/Report1_2
+++ b/src/choiwonbin/report1/Report1_2
@@ -1,3 +1,22 @@
2-7번 번 문제
-정답 :
\ No newline at end of file
+//2-7. 다음 문장들의 출력 결과를 적으세요. 오류가 있는 문장의 경우, '오류' 라고 적으세요.
+
+System.out.println("1" + "2");
+System.out.println(true+"");
+System.out.println('A' + 'B');
+System.out.println('1' + 2);
+System.out.println('1' + '2');
+System.out.println('J' +"ava");
+System.out.println(true + null);
+
+정답 :
+
+
+System.out.println("1" + "2"); 12
+System.out.println(true+""); true
+System.out.println('A' + 'B'); 131
+System.out.println('1' + 2); 51
+System.out.println('1' + '2'); 99
+System.out.println('J' +"ava"); jave
+System.out.println(true + null); 오륲
diff --git a/src/choiwonbin/report1/Report1_3.java b/src/choiwonbin/report1/Report1_3.java
index a474553..98f23bc 100644
--- a/src/choiwonbin/report1/Report1_3.java
+++ b/src/choiwonbin/report1/Report1_3.java
@@ -1,11 +1,26 @@
package choiwonbin.report1;
// 2-8 번 문제 <- 이렇게 문제 번호 작성 필수
+// 아래는 변수 x, y, z의 값을 서로 바꾸는 예제이다. 결과와 같이 출력되도록 코드를 넣으세요.
+
+//예상 결과 : x=2, y=3, z=1
+
public class Report1_3 {
public static void main(String[] args) {
- // 정답 작성
- // Ex)
- AddClass addClass = new AddClass();
- addClass.test();
+
+ int x = 1;
+ int y = 2;
+ int z = 3;
+
+ int tmp = y;
+ y = z;
+ z = x;
+ x = tmp;
+
+
+
+ System.out.println("x="+x);
+ System.out.println("y="+y);
+ System.out.println("z="+z);
}
}
diff --git a/src/choiwonbin/report2/Report2_1 b/src/choiwonbin/report2/Report2_1
new file mode 100644
index 0000000..666046d
--- /dev/null
+++ b/src/choiwonbin/report2/Report2_1
@@ -0,0 +1,19 @@
+
+byte b = 10;
+char ch = 'A';
+int i = 100;
+long l = 1000L;
+//3-1. 다음 중 형변환을 생략할 수 있는 것은? (모두 고르시오)
+b = (byte)i;
+ch = (char)b;
+short s = (short)ch;
+float f = (float)l;
+i = (int)ch;
+
+
+
+
+* 정답
+
+float f = (float)l;
+i = (int)ch;
diff --git a/src/choiwonbin/report2/Report2_2.java b/src/choiwonbin/report2/Report2_2.java
index e2f2bfc..f2cda57 100644
--- a/src/choiwonbin/report2/Report2_2.java
+++ b/src/choiwonbin/report2/Report2_2.java
@@ -1,7 +1,107 @@
package choiwonbin.report2;
// 3-2번 문제
+// 다음 연산의 결과와 그 이유를 적으세요.
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);
+ System.out.println(y += 10 - x++);
+ System.out.println(x += 2);
+ System.out.println(!('A' <= c && c <= 'Z'));
+ System.out.println('C' - c);
+ System.out.println('5' - '0');
+ System.out.println(c + 1);
+ System.out.println(++c);
+ System.out.println(c++);
+ System.out.println(c);
+
+
}
}
+
+
+/* 정답
+
+1. y >= 5 || x < 0 && x > 2
+
+
+x < 0 && x > 2
+x는 0보다 작거나 2보다 크면 true 값을 반환함
+=> 조건이 일치하지 않으므로 false 값을 반환함
+
+y >= 5 or false
+y >= 5 : y는 5보다 크거나 같으면 true
+=> y가 5보다 크거나 같으면 or false 중 하나만 일치하면 true를 반환함.
+
+true || false && false
+
+논리 연산자에서 &&은 ||보다 우선 순위가 높으므로
+
+true || false => true 값이 출력된다
+
+2. y += 10 - x++
+
+x++는 후위형이기 때문에 x값이 증가되지 않은 생태에서
+계산되어 10-2 된 후 x에 값이 1 증가한다
+5 + 8 이기때문에
+13 이 출력된다
+
+3. 앞에서 의 값이 1증가하여 3이 되었고,
+x +=2 의 경우 x에 2를 더하고 x값에 다시 대입하기 대문에
+3 + 2 가 되어 5가 x에 값에 대입되면서
+
+5가 출력된다
+
+4. c의 내용 문자 'A'가 조건에 부합하는지 아닌지를 확인 하는 조건식이다.
+'A' <= c && c <= 'Z' => 'A' <= 'A' && 'A' <= 'Z' 가 되고
+true && true 지만 놀리부정연산(!)을 수행하셔
+true => false 로 바뀌게 되어
+
+false 가 출력된다.
+
+
+5. 문자 'C'와 char c 는 int 보다 작으므로
+int 로 변환하여 연산을 수행한다.
+
+C는 67, char c = 'A' 이므로 A는 65
+67-65 = 2
+
+2가 출력된다
+
+6. 5번 문제와 마찬가지로 문자로 변환된 '5'와 '0'을 int로 변환하여
+연산을 수행하는데
+
+5 = 53, 0 = 48
+53-48 = 5
+
+5가 출력된다.
+
+6. 5번 문제와 마찬가지로 문자 'A'에 int값 1을 추가한다.
+'A' = 65 + 1
+
+1이 출력된다.
+
+
+7. char 'A'에 char 1 을 증가연산자를 구현 형식이며,
+char c를 출력하기 전에
+char C = 'A' + '1' 을 더하게 되므로 B로 변 한뒤 c에 값을 입력하여 char c = 'B' 를 대입한다.
+
+변한 c를 pirnt 하므로
+
+B를 출력한다.
+
+8. 변수 char c를 호출하여 출력한 뒤, 증가 하기 때문에
+호출 당시의 값은 B이므로
+
+B를 출력한다.
+
+9. 8번에서 후위 증가연산자의 영항으로 B 에서 C 로 증가하여
+
+C를 출력한다.
+
+
+ */
diff --git a/src/choiwonbin/report2/Report2_3.java b/src/choiwonbin/report2/Report2_3.java
new file mode 100644
index 0000000..fc459c0
--- /dev/null
+++ b/src/choiwonbin/report2/Report2_3.java
@@ -0,0 +1,17 @@
+package choiwonbin.report2;
+
+//3-3. 아래는 변수의 num 값 중에서 백의 자리 이하를 버리는 코드이다.
+//만일 변수 num의 값이 '456'이라면 '400'이 되고, '111'이라면 '100'이 된다.
+//알맞은 코드를 넣으시오.
+
+public class Report2_3 {
+
+ public static void main(String[] args) {
+
+
+ int num = 423;
+
+ System.out.print(num/100*100);
+}
+}
+
diff --git a/src/choiwonbin/report2/Report2_4.java b/src/choiwonbin/report2/Report2_4.java
new file mode 100644
index 0000000..ed8ea0d
--- /dev/null
+++ b/src/choiwonbin/report2/Report2_4.java
@@ -0,0 +1,24 @@
+package choiwonbin.report2;
+
+//3-4. 아래의 코드는 사과를 담는데 필요한 바구니(버켓)의 수를 구하는 코드이다.
+//만일 사과의 수가 123개이고 하나의 바구니에는 10개의 사과를 담을 수 있다면, 13개의 바구니가 필요할 것이다.
+//알맞은 코드를 넣으시오.
+
+public class Report2_4 {
+
+ public static void main(String[] args) {
+
+ int numOfApples = 222; // 사과의 개수
+ int sizeOfBucket = 10; // 바구니의 크기(바구니에 담을 수 있는 사과의 개수)
+ int numOfBucket = (numOfApples/sizeOfBucket); // 모든 사과를 담는데 필요한 바구니의 수
+
+ if(numOfApples%sizeOfBucket <= 0 ){
+ System.out.println("필요한 바구니의 수 :"+numOfBucket);
+ }
+ else {
+ ++numOfBucket;
+ System.out.println("필요한 바구니의 수 :" + numOfBucket);
+ }
+ }
+ }
+//예상 결과 -> 필요한 바구니의 수 :13
diff --git a/src/choiwonbin/report2/Report2_5.java b/src/choiwonbin/report2/Report2_5.java
new file mode 100644
index 0000000..bb4e798
--- /dev/null
+++ b/src/choiwonbin/report2/Report2_5.java
@@ -0,0 +1,10 @@
+package choiwonbin.report2;
+
+public class Report2_5 {
+
+ public static void main(String[] args) {
+
+ int num = -10;
+ System.out.println(num > 0 ? "양수":(num < 0 ? "음수" : "0"));
+ }
+}
diff --git a/src/choiwonbin/report2/Report2_6.java b/src/choiwonbin/report2/Report2_6.java
new file mode 100644
index 0000000..c3e471e
--- /dev/null
+++ b/src/choiwonbin/report2/Report2_6.java
@@ -0,0 +1,17 @@
+package choiwonbin.report2;
+
+public class Report2_6 {
+
+ public static void main(String[] args) {
+ int fahrenheit = 100;
+ float celcius = (int)((5/9f * (fahrenheit - 32))*100 + 0.5) / 100f;
+
+ System.out.println("Fahrenheit:"+fahrenheit);
+ System.out.println("Celcius:"+celcius);
+
+
+ }
+
+
+}
+
diff --git a/src/choiwonbin/report3/Report3_1 b/src/choiwonbin/report3/Report3_1
index 5edd550..a6b6272 100644
--- a/src/choiwonbin/report3/Report3_1
+++ b/src/choiwonbin/report3/Report3_1
@@ -1,3 +1,53 @@
// 4-1번 문제
+//4-1. 다음의 문장들을 조건식으로 표현해보세요.
+
+//int형 변수 x가 10보다 크고 20보다 작을 때 true인 조건식
+
+//char형 변수 ch가 공백이나 탭이 아닐 때 true인 조건식
+
+//char형 변수 ch가 'x' 또는 'X'일 때 true인 조건식
+
+//char형 변수 ch가 숫자('0'~'9')일 때 true인 조건식
+
+//char형 변수 ch가 영문자(대문자 또는 소문자)일 때 true인 조건식
+
+//int형 변수 year가 400으로 나눠떨어지거나 또는 4로 나눠떨어지고 100으로 나눠떨어지지 않을때 true인 조건식
+
+//boolean형 변수 powerOn이 false일 때 true인 조건식
+
+//문자열 참조변수 str이 "yes"일 때 true인 조건식
+
정답 :
+
+1. int x = 0
+ if( 10 < x && x < 20 ){
+ }
+
+2. char ch = 'c'
+ if(!(ch == ' ' || ch == '\t')){
+ }
+
+3. char ch = 'x'
+ if(ch == 'x' || ch == 'X')
+
+4. char ch = '2';
+ if ( 48 <= ch && ch <= 59 ){
+ }
+
+5 char ch = 'x';
+ if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z' ){
+ }
+
+6. int year = 400;
+ if( year%400==0 || year%4==0 && year%100!=0){
+
+ }
+
+7. if(!powerOn 또는 powerOn==false){
+
+}
+
+8. if(str.equals("yes") 또는 "yes".equals(str){
+
+}
diff --git a/src/choiwonbin/report3/Report3_10.java b/src/choiwonbin/report3/Report3_10.java
new file mode 100644
index 0000000..4702ef7
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_10.java
@@ -0,0 +1,47 @@
+package choiwonbin.report3;
+
+public class Report3_10 {
+
+ public static void main(String[] args) {
+
+ // 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){
+ System.out.println("더 작은 수를 입력하세요.");
+ }else if (answer == input){
+ 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/choiwonbin/report3/Report3_2.java b/src/choiwonbin/report3/Report3_2.java
new file mode 100644
index 0000000..48db902
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_2.java
@@ -0,0 +1,16 @@
+package choiwonbin.report3;
+//4-2. 1부터 20까지의 정수중에서 2 또는 3의 배수가 아닌 수의 총합을 구하세요.
+public class Report3_2 {
+
+ public static void main(String[] args) {
+
+ int sum = 0;
+
+ for(int i = 0; i <= 20; i++){
+ if((i%2!=0) && (i%3!=0)){
+ sum +=i;
+ }
+ }
+ System.out.println("sum="+sum);
+ }
+}
diff --git a/src/choiwonbin/report3/Report3_3.java b/src/choiwonbin/report3/Report3_3.java
new file mode 100644
index 0000000..7c44003
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_3.java
@@ -0,0 +1,16 @@
+package choiwonbin.report3;
+
+public class Report3_3 {
+
+ public static void main(String[] args) {
+ //4-3. 1+(1+2)+(1+2+3)+(1+2+3+4)+...+(1+2+3+...+10)의 결과를 계산하세요.
+
+ int sum = 0;
+ int totalSum = 0;
+ for(int i = 0 ; i <= 10; i++ ) {
+ sum += i;
+ totalSum += sum;
+ }
+ System.out.println("totalSum="+totalSum);
+ }
+}
diff --git a/src/choiwonbin/report3/Report3_4.java b/src/choiwonbin/report3/Report3_4.java
new file mode 100644
index 0000000..367881f
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_4.java
@@ -0,0 +1,27 @@
+package choiwonbin.report3;
+
+public class Report3_4 {
+ public static void main(String[] args) {
+
+ //4-4. 1+(-2)+3+(-4)+...과 같은 식으로 계속 더해나갔을 때,
+ //몇까지 더해야 총합이 100 이상이 되는지 구하세요.
+
+
+ int sum = 0; // 총합을 저장할 변수
+ int s = 1; // 값의 부호를 바꿔주는데 사용할 변수
+ int num = 0;
+ for(int i = 1 ; sum < 100 ; i++){
+ if(i%2 == 0){
+ num = i*(-s);
+ }else
+ num = i* s;
+
+ sum += num;
+
+ System.out.println("num="+num);
+ System.out.println("sum="+sum);
+ }
+
+ }
+}
+
diff --git a/src/choiwonbin/report3/Report3_5.java b/src/choiwonbin/report3/Report3_5.java
new file mode 100644
index 0000000..55c77e1
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_5.java
@@ -0,0 +1,26 @@
+package choiwonbin.report3;
+
+public class Report3_5 {
+
+ public static void main(String[] args) {
+
+ //4-5. 다음의 for문을 while문으로 변경하세요.
+
+ int i = 0;
+
+
+ while (i < 10) {
+ i++;
+ int j = 0;
+ while(j < i ) {
+ j++;
+ System.out.print("*");
+ }
+ System.out.println();
+ }
+
+
+ }//end of main
+} // end of class
+
+
diff --git a/src/choiwonbin/report3/Report3_6.java b/src/choiwonbin/report3/Report3_6.java
new file mode 100644
index 0000000..540cc47
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_6.java
@@ -0,0 +1,22 @@
+package choiwonbin.report3;
+
+public class Report3_6 {
+ public static void main(String[] args) {
+ //두 개의 주사위를 던졌을 때, 눈의 합이 6이 되는 모든 경우의 수를 출력하는 프로그램을 작성하세요.
+
+ int value = 0;
+
+
+ while(value < 6) {
+ value++;
+ for(int i = 1 ; i <=6 ; i++) {
+ if(value+i == 6) {
+ System.out.print("value=" + value + " ");
+ System.out.println("i=" + i);
+ }
+ }
+ }
+ }
+}
+
+
diff --git a/src/choiwonbin/report3/Report3_7.java b/src/choiwonbin/report3/Report3_7.java
new file mode 100644
index 0000000..840809e
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_7.java
@@ -0,0 +1,19 @@
+package choiwonbin.report3;
+
+public class Report3_7 {
+ //4-7. 숫자로 이루어진 문자열 str이 있을 때, 각 자리의 합을 더한 결과를 출력하는 코드를 완성하세요.
+ //만일 문자열이 "12345"라면, ‘1+2+3+4+5’의 결과인 15를 출력이 출력되어야 합니다.
+ public static void main(String[] args) {
+
+ String str = "12345";
+ int sum = 0;
+
+ for (int i = 0; i < str.length(); i++) {
+ sum += str.charAt(i) - '0';
+ }
+
+ System.out.println("sum=" + sum);
+ }
+}//예상 결과 : sum=15
+
+
diff --git a/src/choiwonbin/report3/Report3_8.java b/src/choiwonbin/report3/Report3_8.java
new file mode 100644
index 0000000..663cb50
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_8.java
@@ -0,0 +1,16 @@
+package choiwonbin.report3;
+
+public class Report3_8 {
+ public static void main(String[] args) {
+
+ //4-8. Math.random()을 이용해서 1부터 6 사이의 임의의 정수를 변수 value에 저장하는 코드를 완성하세요.
+
+ int value = ((int) (Math.random() * 6) + 1);
+
+ System.out.println("value =" + value) ;
+
+ }
+
+
+}
+
diff --git a/src/choiwonbin/report3/Report3_9.java b/src/choiwonbin/report3/Report3_9.java
new file mode 100644
index 0000000..9ba70bb
--- /dev/null
+++ b/src/choiwonbin/report3/Report3_9.java
@@ -0,0 +1,21 @@
+package choiwonbin.report3;
+
+public class Report3_9 {
+ public static void main(String[] args) {
+//4-9. int 타입의 변수 num이 있을 때, 각 자리의 합을 더한 결과를 출력하는 코드를 완성하세요.
+//만일 변수 num의 값이 12345라면, ‘1+2+3+4+5’의 결과인 15를 출력하세요.
+//문자열로 변환하지 말고 숫자로만 처리하세요.
+
+ int num = 12345;
+ int sum = 0;
+
+ while(num > 0){
+ sum += num%10;
+ num /= 10;
+ }
+
+
+ System.out.println("sum=" + sum);
+
+ }
+}
diff --git a/src/choiwonbin/report4/Report4_1 b/src/choiwonbin/report4/Report4_1
index 3766451..953aec3 100644
--- a/src/choiwonbin/report4/Report4_1
+++ b/src/choiwonbin/report4/Report4_1
@@ -1,3 +1,16 @@
// 5-1 번 문제
-정답 :
\ No newline at end of file
+//5-1. 다음은 배열을 선언하거나 초기화한 것이다. 잘못된 것을 고르고 그 이유를 설명하세요.
+int[] arr[];
+int[] arr = {1,2,3,};
+int[] arr = new int[5];
+int[] arr = new int[5]{1,2,3,4,5};
+int arr[5];
+int[] arr[] = new int[3][];
+
+
+
+정답 :
+int[] arr= new int[5]{1,2,3,4,5};
+int arr[5]
+
diff --git a/src/choiwonbin/report4/Report4_2.java b/src/choiwonbin/report4/Report4_2.java
new file mode 100644
index 0000000..e0fcb82
--- /dev/null
+++ b/src/choiwonbin/report4/Report4_2.java
@@ -0,0 +1,21 @@
+package choiwonbin.report4;
+
+public class Report4_2 {
+ public static void main(String[] args) {
+
+ //5-2. 다음과 같은 배열이 있을 때, arr[3].length의 값은?
+ int[][]arr = {
+ {5, 5, 5, 5, 5},
+ {10, 10, 10},
+ {20, 20, 20, 20},
+ {30, 30}
+ };
+ System.out.print(arr[3].length);
+ }
+}
+
+// arr[0][i] 5,5,5,5,5
+// arr[1][i] 10,10,10
+// arr[2][i] 20,20,20,20
+// arr[3][i] 30,30
+// arr[3].length 는 배열의 크기를 물어보는 것이므로, 배열의 arr[3]의 배열의 크기는 2.
\ No newline at end of file
diff --git a/src/choiwonbin/report4/Report4_3.java b/src/choiwonbin/report4/Report4_3.java
new file mode 100644
index 0000000..da35127
--- /dev/null
+++ b/src/choiwonbin/report4/Report4_3.java
@@ -0,0 +1,19 @@
+package choiwonbin.report4;
+
+public class Report4_3 {
+
+ public static void main(String[] args) {
+
+ //5-3. 배열 arr에 담긴 모든 값을 더하는 프로그램을 완성하세요.
+ int[] arr = {10, 20, 30, 40, 50};
+ int sum = 0;
+
+ for(int i = 0 ; i< arr.length ; i++){
+ sum += arr[i];
+ }
+
+ System.out.println("sum="+sum);
+
+
+ }
+}
diff --git a/src/choiwonbin/report4/Report4_4.java b/src/choiwonbin/report4/Report4_4.java
new file mode 100644
index 0000000..fcdb456
--- /dev/null
+++ b/src/choiwonbin/report4/Report4_4.java
@@ -0,0 +1,31 @@
+package choiwonbin.report4;
+
+public class Report4_4 {
+
+ public static void main(String[] args) {
+
+ //5-4. 2차원 배열 arr에 담긴 모든 총합과 평균을 구하는 프로그램을 완성하세요.
+
+ int[][] arr = {
+ { 5, 5, 5, 5, 5 },
+ { 10, 10, 10, 10, 10 },
+ { 20, 20, 20, 20, 20 },
+ { 30, 30, 30, 30, 30 }
+ };
+
+ int total = 0;
+ float average = 0;
+
+
+ for(int i = 0 ; i < arr.length ; i++){
+ 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");
+ }
+ }
+ } // main의 끝
+}
diff --git a/src/choiwonbin/report5/Report5_2.java b/src/choiwonbin/report5/Report5_2.java
index 48b2b52..321e843 100644
--- a/src/choiwonbin/report5/Report5_2.java
+++ b/src/choiwonbin/report5/Report5_2.java
@@ -10,4 +10,4 @@ public static void main(String[] args) {
class Student {
// 정답
-}
+}
\ No newline at end of file