-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathProb01.java
More file actions
38 lines (29 loc) · 1009 Bytes
/
Copy pathProb01.java
File metadata and controls
38 lines (29 loc) · 1009 Bytes
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
package practice02;
import java.util.Scanner;
public class Prob01 {
public static void main(String[] args) {
final int[] MONEYS = { 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1 };
Scanner sc = new Scanner(System.in);
int num;
System.out.print("금액: ");
num = sc.nextInt();
if (num < 0) {
num = 0;
}
int[] changes = {
num / 50000,
(num % 50000) / 10000,
((num % 50000) % 10000) / 5000,
(((num % 50000) % 10000) % 5000) / 1000,
((((num % 50000) % 10000) % 5000) % 1000) / 500,
(((((num % 50000) % 10000) % 5000) % 1000) % 500) / 100,
((((((num % 50000) % 10000) % 5000) % 1000) % 500) % 100) / 50,
((((((num % 50000) % 10000) % 5000) % 1000) % 500) % 50) / 10,
(((((((num % 50000) % 10000) % 5000) % 1000) % 500) % 50) % 10) / 5,
((((((((num % 50000) % 10000) % 5000) % 1000) % 500) % 50) % 10) % 5) / 1
};
for (int i = 0; i < MONEYS.length; i++) {
System.out.println(MONEYS[i] + "원 : " + changes[i] + "개");
}
}
}