Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/hanghae-java-study-12.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
2 changes: 2 additions & 0 deletions src/parkseongmin/report1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.iml
3 changes: 3 additions & 0 deletions src/parkseongmin/report1/Report1_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2-4번 문제

정답 :1,2,3,4
10 changes: 10 additions & 0 deletions src/parkseongmin/report1/Report1_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
2-7번 번 문제

정답 :
System.out.println("1" + "2"); 12
System.out.println(true+""); true
System.out.println('A' + 'B'); AB
System.out.println('1' + 2); 오류 숫자와 문자열 결합 불가
System.out.println('1' + '2'); 12
System.out.println('J' +"ava"); 오류 '' ""통일 필요
System.out.println(true + null); true
17 changes: 17 additions & 0 deletions src/parkseongmin/report1/Report1_3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package parkseongmin.report1;
// 2-8 번 문제 <- 이렇게 문제 번호 작성 필수
public class Report1_3 {
public static void main(String[] args){
int x = 1;
int y = 2;
int z = 3;

x = x+1;
y += 1;
z %= 2;

System.out.println("x="+x);
System.out.println("y="+y);
System.out.println("z="+z);
}
}
11 changes: 11 additions & 0 deletions src/parkseongmin/report1/report1.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" packagePrefix="parkseongmin.report1" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
2 changes: 2 additions & 0 deletions src/parkseongmin/report2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.iml
.idea
3 changes: 3 additions & 0 deletions src/parkseongmin/report2/Report2_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2-4번 문제

정답 :1,3
20 changes: 20 additions & 0 deletions src/parkseongmin/report2/Report2_2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package parkseongmin.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); // true // y >= 5 true, x < 0 False, x >2 False 이므로0 true, False 중 하나가 참이므로
System.out.println(y += 10 - x++); // 13 // y = 5+10로 y = 15이고 x는 2이므로 15-2이다. ++ 후위 증가 연산자로 x의 값은 이후 3이고 y값은 13이다.
System.out.println(x += 2); // 5 // x는 현재 3이고 +2를 더 한 값을 대입하면 5이다.
System.out.println(!('A' <= c && c <= 'Z')); // False // 'A'와 'Z'는 문자열이므로 오류
System.out.println('C' - c); // 2 // 'A'는 65, 'C'는 67이므로 2
System.out.println('5' - '0'); // 5 // 모두 문자열이므로 값을 변환해준다. '5'는 53 '0'은 48이므로
System.out.println(c + 1); // 66 // 숫자 1과 결합하기 위해 자동으로 int(A) 적용되어 'A'는 65, 65 + 1 = 66
System.out.println(++c); // B // 'A'는 65, 1을 먼저 증가 = 66 는 문자열 B
System.out.println(c++); // B // 현재 c의 값은 문자열 B를 출력하고 이후 c의 값은 문자열 C가 된다.
System.out.println(c); // C // 현재 문자열 값인 C를 출력
}
}
8 changes: 8 additions & 0 deletions src/parkseongmin/report2/Report2_3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package parkseongmin.report2;
// 3-3번 문제
public class Report2_3 {
public static void main(String[] args){
int num = 456;
System.out.println((int)Math.floor(num/100) *100);
}
}
11 changes: 11 additions & 0 deletions src/parkseongmin/report2/Report2_4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package parkseongmin.report2;
// 3-4번 문제
public class Report2_4 {
public static void main(String[] args){
int numOfApples = 123; // 사과의 개수
int sizeOfBucket = 10; // 바구니의 크기(바구니에 담을 수 있는 사과의 개수)
int numOfBucket = (int)Math.ceil(numOfApples/(float)sizeOfBucket); // 모든 사과를 담는데 필요한 바구니의 수
// 앞에 unmOfBucket이 int값으로 정의되어 있으므로 float 변환 후 다시 int로 변환해준다
System.out.println("필요한 바구니의 수 :"+numOfBucket);
}
}
8 changes: 8 additions & 0 deletions src/parkseongmin/report2/Report2_5.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package parkseongmin.report2;
// 3-5번 문제
public class Report2_5 {
public static void main(String[] args){
int num = 10;
System.out.println( num > 0 ? "양수" : num < 0 ? "음수" : 0 );
}
}
12 changes: 12 additions & 0 deletions src/parkseongmin/report2/Report2_6.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package parkseongmin.report2;
// 3-6번 문제
public class Report2_6 {
public static void main(String[] args){
int fahrenheit = 100;
float celcius = ((float) 5/9*(fahrenheit-32)*100 - (float) Math.floor((double) 5/9*(fahrenheit-32)*100) < 0.5 ? (float) Math.floor((double) 5/9*(fahrenheit-32)*100)/100:
(float) 5/9*(fahrenheit-32)*100 - (float) Math.floor((double) 5/9*(fahrenheit-32)*100) >= 0.5 ? (float) Math.ceil((double) 5/9*(fahrenheit-32)*100)/100 : 0);
// 삼항 연산자에서 조건을 2개 넣으려면 :를 꼭 3개 이상 사용해야하는지 궁금합니다.
System.out.println("Fahrenheit:"+fahrenheit);
System.out.println("Celcius:"+celcius);
}
}
2 changes: 2 additions & 0 deletions src/parkseongmin/report3/.gitinore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.iml
6 changes: 6 additions & 0 deletions src/parkseongmin/report3/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 126 additions & 0 deletions src/parkseongmin/report3/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/parkseongmin/report3/Report3_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
4-1번 문제

정답 :
int x; ( 10 < x && x < 20 )
char ch; ( ch == ' ' || ch == '\t' || ch=='\n')
char ch; ( ch == 'x' || ch == 'X')
char ch; ('0' <= ch && ch <= '9')
char ch; ('A' <= ch && ch <= 'Z' || 'a' <= ch && ch <= 'z')
int year; (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
boolean powerOn; powerOn = false; System.out.println(true)

str.equals("yes")
str.equalsIgnoreCase("yes")
25 changes: 25 additions & 0 deletions src/parkseongmin/report3/Report3_2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 4-2번 문제
class Exercise4_2_1 {
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);
}
}

// 다른 정답
class Exercise4_2_2 {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 20; i++) {
if (i % 2 == 0 || i % 3 == 0){
continue;
} sum += i;
}
System.out.println("sum=" + sum);
}
}
12 changes: 12 additions & 0 deletions src/parkseongmin/report3/Report3_3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 4-3번 문제
class Exercise4_3 {
public static void main(String[] args) {
int sum = 0;
int totalSum = 0;
for (int i = 1; i <= 10; i ++){
sum += i;
totalSum += sum;
}
System.out.println("totalSum="+totalSum);
}
}
14 changes: 14 additions & 0 deletions src/parkseongmin/report3/Report3_4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 4-4번 문제
class Exercise4_4 {
public static void main(String[] args) {
int sum = 0; // 총합을 저장할 변수
int s = 1; // 값의 부호를 바꿔주는데 사용할 변수
int num = 0;
for (int i = 1; sum < 100; i++, s = -s){
num = s*i;
sum += num;
}
System.out.println("num="+num);
System.out.println("sum="+sum);
}
}
Loading