Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1주차 Assignment - 이승현 #9

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
29 changes: 29 additions & 0 deletions leeseunghyun/first-java-assignment/.gitignore
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions leeseunghyun/first-java-assignment/.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 leeseunghyun/first-java-assignment/.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 leeseunghyun/first-java-assignment/.idea/modules.xml

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

11 changes: 11 additions & 0 deletions leeseunghyun/first-java-assignment/first-java-assignment.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$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
80 changes: 80 additions & 0 deletions leeseunghyun/first-java-assignment/src/assigns/Test1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package assigns;

// 다음 조건을 만족하도록 Cylinder 클래스를 작성합니다.
class Cylinder {

public static final double PI = 3.14;// 원주율 3.14를 정적 상수 PI로 선언과 동시에 초기화

int x, y;// 정수형 원의 중심 좌표 x, y를 선언

double r;// 실수형 원의 반지름 r을 선언

int height = 10;// 정수형 원기둥의 높이 height를 10으로 선언과 동시에 초기화

public Cylinder(int x, int y, double r) {
this.x = x;
this.y = y;
this.r = r;
}// 생성자1: 정수 인자 x, y 와 실수 인자 r을 전달 받아서 해당 필드 값을 초기화


public Cylinder(int x, int y, int height, double r) {
this.x = x;
this.y = y;
this.height = height;
this.r = r;
}// 생성자2: 정수 인자 x, y, height 와 실수 인자 r을 전달 받아서 해당 필드 값을 초기화


public double circlearea() {
return PI * r * r;
}// circleArea 메서드: PI를 이용하여 원의 면적 반환

public double volume() {
return (PI * r * r) * height;
}// volume 메서드: 면적과 높이를 이용하여 부피를 반환


public double surfaceArea() {
return 2 * (PI * r * r) + (2 * PI * r) * height;
}// surfaceArea 메서드: PI를 이용하여 원기둥의 겉넓이를 반환


public Cylinder move(int dx, int dy) {
this.x += dx;
this.y += dy;
return this;
} // move 메서드: 정수 인자 dx, dy를 전달 받아서 원의 중심 좌표를 이동
// - 예: 필드 x가 1이고 dx가 10이면 x는 11로 변경되어야 함
// 객체 자신을 반환

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.printf("%.2f\n", c1.circlearea());
System.out.printf("%.1f\n", c1.volume());
System.out.printf("%.2f\n", c1.surfaceArea());

Cylinder c2 = new Cylinder(5,8, 10, 5);
c2.move(12,17).print();
System.out.printf("%.1f\n", c2.circlearea());
System.out.printf("%.1f\n", c2.volume());
System.out.printf("%.1f\n", c2.surfaceArea());
}
}
30 changes: 30 additions & 0 deletions leeseunghyun/first-java-assignment/src/bj_10810/bj_10810/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package bj_10810.bj_10810;

import java.util.Scanner;

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

int M = scanner.nextInt();
int N = scanner.nextInt();

int n1, n2, ball = 0;

int array1[] = new int[M];

for(int i=0;i<N;i = i + 1) {
n1 = scanner.nextInt()-1;
n2 = scanner.nextInt()-1;
ball = scanner.nextInt();

for(int j=n1;j<=n2;j = j + 1) {
array1[j] = ball;
}
}

for(int i=0;i<array1.length;i = i + 1) {
System.out.print(array1[i]+" ");
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions leeseunghyun/first-java-assignment/src/bj_11021/bj_11021/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package bj_11021.bj_11021;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int T = scanner.nextInt();
int i = 1;

while (i <= T) {
int A = scanner.nextInt();
int B = scanner.nextInt();


System.out.println("Case #" + i + ": " + (A + B));
i = i + 1;

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions leeseunghyun/first-java-assignment/src/bj_2439/bj_2439/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package bj_2439.bj_2439;

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int N = scanner.nextInt();

int i = 1;

while (i <= N) {
int J = 1;

while (J <= N - i) {
System.out.print(" ");
J = J + 1;
}

J = 1;
while (J <= i) {
System.out.print("*");
J = J + 1;
}

System.out.println();

i = i + 1;
scanner.close();


}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions leeseunghyun/first-java-assignment/src/bj_2588/bj_2588/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package bj_2588.bj_2588;

import java.util.Scanner;
public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

// 두 개의 정수 입력
int a = scanner.nextInt();
int b = scanner.nextInt();

// 각 자릿수에 대한 곱 계산
int result1 = a * (b % 10);
int result2 = a * ((b % 100) / 10);
int result3 = a * (b / 100);

// 전체 곱 계산
int totalResult = a * b;

// 결과 출력
System.out.println(result1);
System.out.println(result2);
System.out.println(result3);
System.out.println(totalResult);

scanner.close();

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions leeseunghyun/first-java-assignment/src/bj_2884/bj_2884/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package bj_2884.bj_2884;

import java.util.Scanner;

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


int H = scanner.nextInt();
int M = scanner.nextInt();

if (M < 45) {
H = H - 1;
M = 60 - (45 - M);

if (H < 0) {
H = 23;
}
System.out.println(H + " " + M);
} else {
System.out.println(H + " " + (M - 45));
}
scanner.close();

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions leeseunghyun/first-java-assignment/src/bj_9086/bj_9086_/main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package bj_9086.bj_9086_;

import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int T = scanner.nextInt();
scanner.nextLine();

for (int i = 0; i < T; i = i + 1) {
String str = scanner.nextLine(); // 문자열로 입력받기

char[] charArray = str.toCharArray(); //입력받은 문자열을 문자형으로 변환
char first = charArray[0];
char last = charArray[str.length() - 1]; //인덱스는 0 부터 시작

System.out.println(first + "" + last);

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.