MapleStory Finger Point Cute Line Smiley Blinking Hello Kitty Angel MapleStory Finger Point

๐Ÿ’Ž JAVA/๐Ÿ“š๋ช…ํ’ˆ JAVA_ESSENTIAL

หšโ‚Šโœฉโ€งโ‚Š [ๅฎŒ][๋ช…ํ’ˆ JAVA ESSENTIAL] CH2 ์‹ค์Šต๋ฌธ์ œ หšโ‚Šโœฉโ€งโ‚Š

HYEJU01 2021. 9. 25. 00:32

 

"๊ฐœ์ •ํŒ: ๋ช…ํ’ˆ JAVAESSENTIAL(ํ™ฉ๊ธฐํƒœ)"๊ต์žฌ์— ์ˆ˜๋ก๋œ ๋ฌธ์ œ๋“ค์„ ํ’€์–ด์„œ ์˜ฌ๋ฆฝ๋‹ˆ๋‹ค.
๋ฌธ์ œ์˜ ๋ฒˆํ˜ธ๋งŒ ํ‘œ๊ธฐํ•˜๊ณ  ๋‹ต์•ˆ๋งŒ ์ ๋Š” ํ˜•ํƒœ๋กœ ์—…๋กœ๋“œ ํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค.
๊ฐœ์ธ ํ’€์ด์ด๋ฏ€๋กœ ์˜ค๋‹ต์ด ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋ฉฐ ์˜ค๋‹ต ๋ฐœ๊ฒฌ ์‹œ ๋Œ“๊ธ€ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค๐Ÿ˜Š
-
#์ด ํ‘œ์‹œ๋œ ๊ฑด ์•„์ง ํ’€์ง€ ๋ชปํ•œ ๋ฌธ์ œ or ํ—ท๊ฐˆ๋ฆฌ๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค!
์ถ”ํ›„์— ๋‹ค์‹œ ํ’€์–ด์„œ ์˜ฌ๋ฆด ์˜ˆ์ •์ด์—์š”!

-ujeyhx-

 

๐Ÿ”Ž์‹ค์Šต๋ฌธ์ œ

 

 

1)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		int a,b;
		System.out.print("๋‘ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” >>");
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		
		System.out.println(a + "+" + b + "์€ " + (a+b));
		sc.close();
	}
	
}

 

 


2)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		int floor;
		System.out.print("๋ช‡ ์ธต์ธ์ง€ ์ž…๋ ฅํ•˜์„ธ์š” >>");
		Scanner sc = new Scanner(System.in);
		floor = sc.nextInt();
		
		System.out.println(floor * 5 + "m ์ž…๋‹ˆ๋‹ค.");
		sc.close();
	}
	
}

 


3)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int x,y;
		System.out.print("X ๊ฐ’์„ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		y = (int) (Math.pow(x,2)-3*x+7);
		System.out.println("x="+ x +","+" y="+ y);
		sc.close();
	}
	
}

 


4)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int x,y;
		System.out.print("์  (x,y)์˜ ์ขŒํ‘œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		y = sc.nextInt();
		System.out.print("์ ("+ x +","+ y +")์€");
		System.out.print(" (50,50)๊ณผ (100,100)์˜ ์‚ฌ๊ฐํ˜• ");
		if ((50<=x && x<=100)  && (50<=y&& y<=100)) //๋…ผ๋ฆฌ์—ฐ์‚ฐ์ž์‚ฌ์šฉ์ฃผ์˜
			System.out.print("๋‚ด์— ์žˆ์Šต๋‹ˆ๋‹ค.");
		else
			System.out.print("๋‚ด์— ์—†์Šต๋‹ˆ๋‹ค.");
		sc.close();
	}
	
}

 


5)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
	
		
		System.out.print("๋…ผ๋ฆฌ ์—ฐ์‚ฐ์„ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		boolean a = sc.nextBoolean();
		String op = sc.next();
		boolean b = sc.nextBoolean();
		
		switch(op){
			case "AND" :
				if (a && b)
				System.out.println("true");
				else
				System.out.println("false");
				break;
				
			case "OR" :
				if (a || b)
				System.out.println("true");
				else
				System.out.println("false");
				break;
				
			default:
				System.out.println("์ž˜๋ชป์ž…๋ ฅ");
		}
		sc.close();
	}
}


6)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int money;
		int m50000,m10000,m1000,m500,m100,m10,m1;
		System.out.print("๋ˆ์˜ ์•ก์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		money = sc.nextInt();
		
		m50000=money/50000;
		m10000=(money%50000)/10000;
		m1000=(money%50000%10000)/1000;
		m500=(money%50000%10000%1000)/500;
		m100=(money%50000%10000%1000%500)/100;
		m10=(money%50000%10000%1000%500%100)/10;
		m1=(money%50000%10000%1000%500%100%10);
		
		System.out.print("์˜ค๋งŒ์›"+m50000+"๊ฐœ ");
		System.out.print("๋งŒ์›"+m10000+"๊ฐœ ");
		System.out.print("์ฒœ์›"+m1000+"๊ฐœ ");
		System.out.print("500์›"+m500+"๊ฐœ ");
		System.out.print("100์›"+m100+"๊ฐœ ");
		System.out.print("10์›"+m10+"๊ฐœ ");
		System.out.print("1์›"+m1+"๊ฐœ ");
		
		sc.close();
	}
}

 


7)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		String grade;
		System.out.print("ํ•™์ ์„ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		grade = sc.next();
		
		switch (grade) {
		case "A": case "B":
			System.out.print("Excellent");
			break;
		case "C": case "D":
			System.out.print("Good");
			break;
		case "F":
			System.out.print("Bye");
			break;
		default :
			System.out.print("์ž˜๋ชป์ž…๋ ฅํ•˜์…จ์Šต๋‹ˆ๋‹ค.");
		}
		sc.close();
	}
}

 

 


8)

//FOR ๋ฌธ

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int price = 0;
		System.out.print("์ปคํ”ผ ์ฃผ๋ฌธํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		String coffee = sc.next();
		int num = sc.nextInt();
		
		if (coffee.equals("์นดํ‘ธ์น˜๋…ธ"))
			price = 3000;
		else if (coffee.equals("์•„๋ฉ”๋ฆฌ์นด๋…ธ"))
			price = 2500;
		else if (coffee.equals("์—์Šคํ”„๋ ˆ์†Œ"))
			price = 2000;
		else if (coffee.equals("์นดํŽ˜๋ผ๋–ผ"))
			price = 3500;

		System.out.print((price*num) +"์›์ž…๋‹ˆ๋‹ค.");
		
		sc.close();
		
	}
}

 

//SWITCH ๋ฌธ
import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int price = 0;
		System.out.print("์ปคํ”ผ ์ฃผ๋ฌธํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		String coffee = sc.next();
		int num = sc.nextInt();
		
		switch (coffee) {
		case "์นดํ‘ธ์น˜๋…ธ":
			price = 3000;
			break;
		case "์•„๋ฉ”๋ฆฌ์นด๋…ธ":
			price = 2500;
			break;
		case "์—์Šคํ”„๋ ˆ์†Œ":
			price = 2000;
			break;
		case "์นดํŽ˜๋ผ๋–ผ":
			price = 3500;
			break;
		}
		
		System.out.print((price*num) +"์›์ž…๋‹ˆ๋‹ค.");
		
		sc.close();
		
	}
}

 


9)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int num;
		System.out.print("1~99 ์‚ฌ์ด์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		
		int first = num/10;
		int second = num%10;
		int clap = 0;
		
		if (first != 0 && first % 3 == 0)
			clap ++;
		if (second != 0 && second % 3 == 0)
			clap ++;
		
		
		if (clap == 0)
				System.out.print("๋ฐ•์ˆ˜ ์—†์Œ");
		else if (clap == 1)
				System.out.print("๋ฐ•์ˆ˜ ์ง");
		else if (clap == 2)
				System.out.print("๋ฐ•์ˆ˜ ์ง์ง");
                
       sc.close();
	}
}

 

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int num;
		System.out.print("1~99 ์‚ฌ์ด์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		
		int first = num/10;
		int second = num%10;
		
		if (first == 3 && first == 6 && first == 9 )
			System.out.print("๋ฐ•์ˆ˜ ์ง");
		else
		if (second == 3 && second == 6 && second == 9)
			System.out.print("๋ฐ•์ˆ˜ ์ง์ง");
		else
			System.out.print("๋ฐ•์ˆ˜ ์—†์Œ.");
		
	
		sc.close();
	}
}

10)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		int price = 0;
		System.out.print("์ปคํ”ผ ์ฃผ๋ฌธํ•˜์„ธ์š”>>");
		Scanner sc = new Scanner(System.in);
		String coffee = sc.next();
		int num = sc.nextInt();
		double priceSum = 0;
		
		switch (coffee) {
		case "์นดํ‘ธ์น˜๋…ธ":
			price = 3000;
			break;
		case "์•„๋ฉ”๋ฆฌ์นด๋…ธ":
			price = 2500;
			break;
		case "์—์Šคํ”„๋ ˆ์†Œ":
			price = 2000;
			break;
		case "์นดํŽ˜๋ผ๋–ผ":
			price = 3500;
			break;
		}
		
		priceSum = (price*num);
		
		if (coffee.equals("์—์Šคํ”„๋ ˆ์†Œ")) {
			if (num>=10)
					priceSum -= ((double) (price*num)) * 0.05;
		}

		
		System.out.print((int)priceSum +"์›์ž…๋‹ˆ๋‹ค.");
		
		sc.close();
		
	}
}

 

 

 


Bonus 1 )

 

 

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		

		
		Scanner sc = new Scanner(System.in);
		System.out.print("์‹์„ ์ž…๋ ฅํ•˜์„ธ์š”>>");
		double op1 = sc.nextDouble(); 
		String op = sc.next();
		double op2 = sc.nextDouble();
		double result = 0;
		
		
		switch (op) {
		case "+":
			result = op1 + op2;
			break;
		case "-":
			result = op1 - op2;
			break;
		case "*":
			result = op1 * op2;
			break;
		case "/":
			if (op2 == 0) {
			System.out.println("0์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค");
			return;
			}
			result = op1 / op2;
			break;
		default :
			System.out.println("์—ฐ์‚ฐ ๊ธฐํ˜ธ๊ฐ€ ์ž˜๋ชป๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
		}
		System.out.println(result);
	
		sc.close();
		
	}
}