archive
[3주차 실습] 3월 14일 Problem Set 본문
1. Take a point (x, y) representing the center of a circle and its radius as a real number, and another point (a, b) as a real number, and determine if it is inside the circle and print it out.
package march14;
import java.util.Scanner;
public class project1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
double x, y, r, a, b;
System.out.println("circle >>");
x=input.nextInt();
y=input.nextInt();
r=input.nextInt();
System.out.println("point >>");
a=input.nextInt();
b=input.nextInt();
double num=(x-a)*(x-a)+(y-b)*(y-b);
if(num<r*r)
System.out.println("점이 원 안에 있습니다.");
else
System.out.println("점이 원 안에 없습니다.");
}
}
실행결과
2. Given an integer amount of money, print how many fifty thousand, ten thousand, one thousand, five hundred, one hundred, fifty, ten, and one won(원) bills/coins it converts to.
package march14;
import java.util.*;
public class project2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int money;
int fiftythousand, tenthousand,thousand, fivehundred, onehundred, fifty, ten, one;
System.out.println("money amount you have>>> ");
Scanner input=new Scanner(System.in);
money=input.nextInt();
fiftythousand=money/50000;
tenthousand=(money%50000)/10000;
thousand=(money%10000)/1000;
fivehundred=(money%1000)/500;
onehundred=(money%500)/100;
fifty=(money%100)/50;
ten=(money%50)/10;
one=money%10;
System.out.printf("%d장의 오만원권, %d장의 만원권, %d장의 천원권이 필요하다.\n", fiftythousand, tenthousand,thousand);
System.out.printf("%d개의 오백원, %d개의 백원, %d개의 오십원, %d개의 십원과 %d개의 1원이 필요하다.", fivehundred, onehundred, fifty, ten, one);
}
}
실행결과
3. Given three integers representing the lengths of the sides of a triangle, determine if a triangle can be constructed from these three numbers.
package march14;
import java.util.*;
public class project3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a, b, c;
System.out.print("length? >>>");
Scanner input=new Scanner(System.in);
a=input.nextInt();
b=input.nextInt();
c=input.nextInt();
if(a>b&&a>c)
if(a<=b+c)
System.out.print("삼각형을 만들 수 있습니다.");
else
System.out.print("삼각형을 만들 수 없습니다.");
else if(b>a&&b>c)
if(b<=a+c)
System.out.print("삼각형을 만들 수 있습니다.");
else
System.out.print("삼각형을 만들 수 없습니다.");
else
if(c<=a+b)
System.out.print("삼각형을 만들 수 있습니다.");
else
System.out.print("삼각형을 만들 수 없습니다.");
}
}
실행결과
++ 이건 그냥 자랑 겸 기억하고 싶어서
비전공자 반이기도 했고 내가 아는 동기 오빠도 자바 처음일 만큼 미숙한 수강생들이 많은 표본집단 속의 나였지만
그래도 스터디를 해서 그런 건지, 아직 수업 초반이라 문제 난이도가 극하이기도 하였지만
80명 수강생 중에 그래도 5번째 정도로 풀고 강의실 뛰쳐나갔다
그 때의 짜릿함이란... 크크 더 열심히 하자! ଘ(੭*ˊᵕˋ)੭
'Java > 23_1 소프트웨어프로젝트' 카테고리의 다른 글
[9주차 실습] 4월 28일 Problem Set (0) | 2023.04.28 |
---|---|
[7주차 실습] 4월 13일 Problem Set (0) | 2023.04.28 |
[6주차 실습] 4월 6일 Problem Set (0) | 2023.04.06 |
[5주차 실습] 3월 30일 Problem Set (0) | 2023.03.31 |
[4주차 실습] 3월 23일 Problem Set (0) | 2023.03.30 |