import javax.swing.JOptionPane;

 public class Solution
 {
     public static void main(String[] args)
     {
         String amountString = JOptionPane.showInputDialog(null, "Enter an amount in int, for example 1156: ",
             "Input Amount", JOptionPane.QUESTION_MESSAGE);
         int amount = Integer.parseInt(amountString);
         int remainingAmount = amount;

         int numberOfOneDollars = remainingAmount / 100;
         remainingAmount = remainingAmount % 100;

         int numberOfQuarters = remainingAmount / 25;
         remainingAmount = remainingAmount % 25;

         int numberOfDimes = remainingAmount / 10;
         remainingAmount = remainingAmount % 10;

         int numberOfNickels = remainingAmount / 5;
         remainingAmount = remainingAmount % 5;

         int numberOfPennis = remainingAmount;

         String output = "Your amount " + amount + " consists of \n" +
             "\t" + numberOfOneDollars + " dollars\n" +
             "\t" + numberOfQuarters + " quarters\n" +
             "\t" + numberOfDimes + " dimes\n" +
             "\t" + numberOfNickels + " nickels\n" +
             "\t" + numberOfPennis + " pennis";

         JOptionPane.showMessageDialog(null, output);
     }
 }

最新文章

  1. JS中将JSON的字符串解析成JSON数据格式《转》
  2. Saltstack数据系统Grains和Pillar(三)
  3. [转]How do I use software from a PPA
  4. 李洪强iOS开发之多线程编程2-NSOperation
  5. volley(2) 参数code : or_barcode, pr_ismsd:false , method:GET
  6. zz 李治国:地图大战本质是争抢O2O入口
  7. In Java, what is the default location for newly created files?
  8. 杭电 2047 阿牛的EOF牛肉串 (递推)
  9. hdu1161Eddy's mistakes
  10. Android 相对布局常用属性
  11. html5知识点:DOM编程
  12. nodeJS里面的模块
  13. 浏览器兼容CSS渐进增强 VS 优雅降级如何选择
  14. Python进阶:切片的误区与高级用法
  15. [转帖]csdn windows 下载整理.
  16. centos6.5配置redis服务 很好用谢谢
  17. 亿级 ELK 日志平台构建部署实践
  18. P2375 [NOI2014]动物园
  19. PAT-GPLT L1-033 - 出生年 - [简单模拟]
  20. ISO 8895-1

热门文章

  1. Ubuntu 下部署asp.net运行环境
  2. spring IOC源码分析(2)
  3. 10 Best Responsive HTML5 Frameworks and Tools
  4. javascript高级编程笔记03(正则表达式)
  5. Jfinal 入门
  6. Memcached(五)Memcached的并发实例
  7. HDU 1560 DNA sequence (IDA* 迭代加深 搜索)
  8. Bootstrap 貌似不错,先做一下记录
  9. TC Asia Competition
  10. Android ListView(Selector 背景图片)