diff --git a/parkyeonji/first-java-assignment/.gitignore b/parkyeonji/first-java-assignment/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/parkyeonji/first-java-assignment/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/.idea/.gitignore b/parkyeonji/first-java-assignment/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/parkyeonji/first-java-assignment/.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/parkyeonji/first-java-assignment/.idea/misc.xml b/parkyeonji/first-java-assignment/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/parkyeonji/first-java-assignment/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/.idea/modules.xml b/parkyeonji/first-java-assignment/.idea/modules.xml new file mode 100644 index 0000000..5a80775 --- /dev/null +++ b/parkyeonji/first-java-assignment/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/first-java-assignment.iml b/parkyeonji/first-java-assignment/first-java-assignment.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/parkyeonji/first-java-assignment/first-java-assignment.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/src/assignments/.idea/.gitignore b/parkyeonji/first-java-assignment/src/assignments/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/parkyeonji/first-java-assignment/src/assignments/.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/parkyeonji/first-java-assignment/src/assignments/.idea/misc.xml b/parkyeonji/first-java-assignment/src/assignments/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/parkyeonji/first-java-assignment/src/assignments/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/src/assignments/.idea/modules.xml b/parkyeonji/first-java-assignment/src/assignments/.idea/modules.xml new file mode 100644 index 0000000..5605fc4 --- /dev/null +++ b/parkyeonji/first-java-assignment/src/assignments/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/src/assignments/.idea/vcs.xml b/parkyeonji/first-java-assignment/src/assignments/.idea/vcs.xml new file mode 100644 index 0000000..bc59970 --- /dev/null +++ b/parkyeonji/first-java-assignment/src/assignments/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/src/assignments/Test1.java b/parkyeonji/first-java-assignment/src/assignments/Test1.java new file mode 100644 index 0000000..e835192 --- /dev/null +++ b/parkyeonji/first-java-assignment/src/assignments/Test1.java @@ -0,0 +1,87 @@ +package assignments; + +// 다음 조건을 만족하도록 Cylinder 클래스를 작성합니다. +class Cylinder { + + // 원주율 3.14를 정적 상수 PI로 선언과 동시에 초기화 + static final double PI = 3.14; + + // 정수형 원의 중심 좌표 x, y를 선언 + int x, y; + + // 실수형 원의 반지름 r을 선언 + double r; + + // 정수형 원기둥의 높이 height를 10으로 선언과 동시에 초기화 + int height = 10; + + // 생성자1: 정수 인자 x, y 와 실수 인자 r을 전달 받아서 해당 필드 값을 초기화 + public Cylinder(int x, int y, double r) { + this.x = x; + this.y = y; + this.r = r; + } + + // 생성자2: 정수 인자 x, y, height 와 실수 인자 r을 전달 받아서 해당 필드 값을 초기화 + public Cylinder(int x, int y, double r, int height) { + this.x = x; + this.y = y; + this.height = height; + this.r = r; + } + + // circleArea 메서드: PI를 이용하여 원의 면적 반환 + double circleArea() { + return r * r * PI; + } + + // volume 메서드: 면적과 높이를 이용하여 부피를 반환 + double volume() { + return r * r * PI * height; + } + + // surfaceArea 메서드: PI를 이용하여 원기둥의 겉넓이를 반환 + double surfaceArea() { + return (r * r * PI * 2) + (2 * PI * r * height); + } + + // move 메서드: 정수 인자 dx, dy를 전달 받아서 원의 중심 좌표를 이동 + // - 예: 필드 x가 1이고 dx가 10이면 x는 11로 변경되어야 함 + // 객체 자신을 반환 + Cylinder move(int dx, int dy) { + this.x += dx; + this.y += dy; + + return this; + } + + void print() { + System.out.println("<"+x+","+y+":"+r+">"); + } +} + + +// 메인메서드 수행시 이렇게 출력되도록 +//<13,15:6.0> +//113.04 +//1130.4 +//602.88 +//<17,25:10.0> +//314.0 +//1570.0 +//942.0 +public class Test1 { + public static void main(String[] args) { + Cylinder c1 = new Cylinder(3,5, 6); + c1.move(10,10).print(); + System.out.println(c1.circleArea()); + System.out.println(c1.volume()); + System.out.println(c1.surfaceArea()); + + Cylinder c2 = new Cylinder(5,8,10,5); + c2.move(12,17).print(); + System.out.println(c2.circleArea()); + System.out.println(c2.volume()); + System.out.println(c2.surfaceArea()); + } +} diff --git a/parkyeonji/first-java-assignment/src/assignments/assignments.iml b/parkyeonji/first-java-assignment/src/assignments/assignments.iml new file mode 100644 index 0000000..fd81f4e --- /dev/null +++ b/parkyeonji/first-java-assignment/src/assignments/assignments.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/parkyeonji/first-java-assignment/src/bj_10810/Main.java b/parkyeonji/first-java-assignment/src/bj_10810/Main.java new file mode 100644 index 0000000..1b41c3e --- /dev/null +++ b/parkyeonji/first-java-assignment/src/bj_10810/Main.java @@ -0,0 +1,29 @@ +package bj_10810; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + int N = scanner.nextInt(); + int M = scanner.nextInt(); + + int i, j, k; + + int array[] = new int[N]; + + for(int x=0;xi;j--) { + System.out.print(" "); + } + for(int k=0;k