-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (26 loc) · 962 Bytes
/
Main.java
File metadata and controls
34 lines (26 loc) · 962 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
package beecrowd1018;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int valor = sc.nextInt();
int valor_inicial = valor;
sc.close();
int[] cedulas = {100, 50, 20, 10, 5, 2, 1};
List<Integer> notas = new ArrayList<>();
for(int i = 0; i < cedulas.length; i++) {
if(valor >= cedulas[i]){
notas.add(valor / cedulas[i]);
valor = valor % cedulas[i];
} else {
notas.add(0);
}
}
System.out.println(valor_inicial);
for(int i = 0; i < notas.size() && i < cedulas.length; i++) {
System.out.printf("%d nota(s) de R$ %d,00%n", notas.get(i), cedulas[i]);
}
}
}