1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | package pack; import java.util.Scanner; public class Test7if { public static void main(String[] args) throws Exception{ // ์กฐ๊ฑด ํ๋จ๋ฌธ if int num = 2; if(num >= 3){ System.out.println("ํฌ๊ตฐ์ฉ"); System.out.println("์ฐธ์ผ ๋"); } System.out.println("๋ค์ ์์
๊ณ์ 1"); num = 5; if(num < 3){ System.out.println("์๊ตฐ์"); System.out.println("๋ ์ฐธ"); }else{ System.out.println("์์ง ์์์"); } System.out.println("๋ค์ ์์
๊ณ์ 2"); int jumsu = 40; if(jumsu >= 70){ //๋ค์ค if if(jumsu >=90){ System.out.println("์ฐ์"); }else{ System.out.println("๋ณดํต"); } }else{ if(jumsu >= 50){ System.out.println("์ ์กฐ"); }else{ System.out.println("๋งค์ฐ ์ ์กฐ"); } } System.out.println("๋ค์ ์์
๊ณ์ 3"); jumsu = 75; String re; if(jumsu >= 90){ re = "์"; }else if(jumsu >= 80){ re = "์ฐ"; }else if(jumsu >= 70){ re = "๋ฏธ"; }else if(jumsu >= 60){ re = "์"; }else{ re = "๊ฐ"; } System.out.println("ํ๊ฐ ๊ฒฐ๊ณผ " + re); //๋ฌธ์ ) ํค๋ณด๋๋ก ๋ถํฐ ์ํ๋ช
, ์๋, ๋จ๊ฐ๋ฅผ ๊ฐ๊ฐ ์
๋ ฅ๋ฐ์ ๊ธ์ก (์๋*๋จ๊ฐ)์ ๊ตฌํ์์ค. //์กฐ๊ฑด: ๊ธ์ก์ด 5๋ง์ ์ด์์ด๋ฉด ๊ธ์ก์ 10%๋ฅผ, ์๋๋ฉด ๊ธ์ก์ 5%๋ฅผ ์ธ๊ธ์ผ๋ก ์ถ๋ ฅ //์ถ๋ ฅ ๋ชจ์์ ์ํ๋ช
: *** ๊ธ์ก:*** ์ธ๊ธ :*** String product; int quant; double hap, tax, price; Scanner sc = new Scanner(System.in); System.out.print("์ํ ์
๋ ฅ:"); product = sc.next(); System.out.print("์๋ ์
๋ ฅ:"); quant = sc.nextInt(); System.out.print("๋จ๊ฐ ์
๋ ฅ:"); price = sc.nextDouble(); hap = price * quant; if(hap < 50000){ tax = (hap * 0.05); }else{ tax = (hap * 0.1); } System.out.println("์ํ๋ช
:" + product + "๋จ๊ฐ" + (int)price + " ์๋ ์
๋ ฅ: " + quant + " ์ด ๊ฐ๊ฒฉ" + hap + " ์" + " ์ธ๊ธ: "+ tax + " ์"); } } | cs |
๋ฐ์ํ
'๐ป ํ๋ก๊ทธ๋๋ฐ > JAVA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
2-9 ์กฐ๊ฑด ํ๋จ๋ฌธ switch II (0) | 2016.06.26 |
---|---|
2-8 ์กฐ๊ฑด ํ๋จ๋ฌธ switch (0) | 2016.06.26 |
2-6 ํฐ ์ ์ Big Decimal (0) | 2016.06.26 |
2-5 ํ๋ก๊ทธ๋จ๋์ค ํค๋ณด๋ ์ ๋ ฅ๊ฐ ๋ฐ๊ธฐ (0) | 2016.06.26 |
2-4 ๋ ผ๋ฆฌ์ฐ์ฐ์ (0) | 2016.06.26 |