-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFareTest.java
More file actions
51 lines (40 loc) · 1.17 KB
/
FareTest.java
File metadata and controls
51 lines (40 loc) · 1.17 KB
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
package chap04;
import java.util.Scanner;
public class FareTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("-----Menu------------");
System.out.println("1. 가정용 (liter당 50원)");
System.out.println("2. 상업용 (liter당 45원)");
System.out.println("3. 공업용 (liter당 30원)");
System.out.println("---------------------");
System.out.println("메뉴를 선택하세요=>");
System.out.println("---------------------");
int menu = scan.nextInt();
System.out.println("사용량을 입력하세요=>");
int amount = scan.nextInt();
int price = 0;
double totalPrice = 0;
switch (menu) {
case 1:
price = amount * 50;
break;
case 2:
price = amount * 45;
break;
case 3:
price = amount * 30;
break;
default:
break;
}
totalPrice = price + (price * 0.05);
System.out.println("=====================");
System.out.println("사용자 코드:" + menu);
System.out.println("사용 요금:" + price);
System.out.println("총수도 요금:" + totalPrice);
System.out.println("=====================");
scan.close();
}
}