12-1) import java.util.Scanner; public class ex12_1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.print("연산>>"); int num1 = sc.nextInt(); String op = sc.next(); int num2 = sc.nextInt(); if(op.equals("+")) { int sum = num1+num2; System.out.println(num1+op+num2+"의 계산 결과는 "+sum); } else if(op.equals("-")) { int sub = nu..
명품JAVA프로그래밍/2장 자바 기본 프로그래밍
11-1) import java.util.Scanner; public class ex11_1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.print("달을 입력하세요(1~12)>>"); int month = sc.nextInt(); //봄일 경우 (3~5) if(month==3||month==4||month==5) { System.out.println("봄"); } //여름일 경우(6~8) else if(month==6||month==7||month==8) { System.out.println("여름"); } //가을일 경우(..
import java.util.Scanner; public class ex10 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.print("첫번째 원의 중심과 반지름 입력>>"); int centerX1 = sc.nextInt(); int centerY1 = sc.nextInt(); int radius1 = sc.nextInt(); System.out.print("두번째 원의 중심과 반지름 입력>>"); int centerX2 = sc.nextInt(); int centerY2 = sc.nextInt(); int radius2 =..
import java.util.Scanner; public class ex9 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.print("원의 중심과 반지름 입력>>"); double centerX = sc.nextDouble(); double centerY = sc.nextDouble(); double radius = sc.nextDouble(); System.out.print("점 입력>>"); double x = sc.nextDouble(); double y = sc.nextDouble(); double result = (c..
import java.util.Scanner; public class ex8 { public static boolean inRect(int x,int y, int rectx1,int recty1, int rectx2, int recty2) { if((x>=rectx1 && x=recty1 && y>400 400 500 500 직사각형과 충돌하지 않는다. 점 (x1,y1), (x2,y2)의 좌표를 입력하시오>>250 250 100 100 직사각형과 충돌한다. 점 (x1,y1), (x2,y2)의 좌표를 입력하시오>>150 150 180 180 직사각형과 충돌하지 않는다.
import java.util.Scanner; public class ex7 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.print("점 (x,y)의 좌표를 입력하시오>>"); int x = sc.nextInt(); int y = sc.nextInt(); if((x>100&&x100&&y>150 150 (150,150)는 사각형 안에 있습니다.