fork download
  1. import java.io.*;
  2. import java.util.*;
  3. public class MoneyCount {
  4. private void doIt() {
  5. BufferedReader br = null;
  6. for( ; ; ) {
  7. try {
  8. int[] a = { 10000, 5000, 2000, 1000, 500, 200, 100, 50, 25, 10, 5, 1, };
  9. int[] b = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
  10. double d = Double.parseDouble(br.readLine());
  11. int num = (int)(d * 100);
  12. if(num == 0) { break; }
  13. if(num < 0 || num != d * 100) { throw new NumberFormatException(); }
  14. int sz = a.length;
  15. for(int i=0; i<sz; i++) {
  16. if(num >= a[i]) {
  17. b[i] = num / a[i];
  18. num -= a[i] * b[i];
  19. }
  20. }
  21. for(int i=0; i<sz; i++) {
  22. if(a[i] >= 100) {
  23. System.out.printf("$%3d: %3d枚\n", a[i] / 100, b[i]);
  24. } else {
  25. System.out.printf("c%3d: %3d枚\n", a[i], b[i]);
  26. }
  27. }
  28. } catch(NumberFormatException ex) {
  29. ex.printStackTrace();
  30. } catch(IOException ex) {
  31. ex.printStackTrace();
  32. }
  33. }
  34. if(br != null) { try { br.close(); } catch(Exception ex) {} }
  35. }
  36. public static void main(String[] args) {
  37. new MoneyCount().doIt();
  38. }
  39. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty