-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoinEx01.java
More file actions
40 lines (31 loc) · 1.01 KB
/
Copy pathCoinEx01.java
File metadata and controls
40 lines (31 loc) · 1.01 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
package java2;
public class CoinEx01 {
int money = 2680;
int restMoney = money;
void restMoneyPrint(int coin) {
System.out.println(coin + "원 개수 : " + restMoney / coin);
restMoney = money % coin;
System.out.println("남은 금액 : " + restMoney);
}
public static void main(String[] args) {
int coinType[] = { 500, 10, 50, 10 };
CoinEx01 coinEx01 = new CoinEx01();
for (int i = 0; i < 4; i++) {
coinEx01.restMoneyPrint(coinType[i]);
}
/* 500*5 100*1, 50*1, 10*3
System.out.println("500원 개수 : "+restMoney/500);
restMoney = money % 500;
System.out.println("남은 금액 : "+restMoney);
System.out.println("100원 개수 : "+restMoney/100);
restMoney = money % 100;
System.out.println("남은 금액 : "+restMoney);
System.out.println("50원 개수 : "+restMoney/50);
restMoney = money % 50;
System.out.println("남은 금액 : "+restMoney);
System.out.println("10원 개수 : "+restMoney/10);
restMoney = money % 10;
System.out.println("남은 금액 : "+restMoney);
*/
}
}