"๊ฐ์ ํ: ๋ช
ํ 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();
}
}