Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test.resti;
- import java.util.Arrays;
- import java.util.List;
- public class AppResti {
- private static final List<Integer> TAGLI = Arrays.asList(200, 100, 50, 20, 10, 5, 2, 1);
- public static void main(String[] args) {
- Integer importo = getImporto(args);
- for (int taglioCorrente : TAGLI) {
- int quantitaTaglioCorrente = importo / taglioCorrente;
- importo = importo % taglioCorrente;
- System.out.println(quantitaTaglioCorrente + " da " + taglioCorrente);
- }
- }
- private static Integer getImporto(String[] args) {
- if (args.length < 1) {
- throw new IllegalArgumentException("Parametro importo non passato");
- }
- return Integer.parseInt(args[0]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement