HW2.10
2024-10-01 12:57:11
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); } }
最新文章
- JS中将JSON的字符串解析成JSON数据格式《转》
- Saltstack数据系统Grains和Pillar(三)
- [转]How do I use software from a PPA
- 李洪强iOS开发之多线程编程2-NSOperation
- volley(2) 参数code : or_barcode, pr_ismsd:false , method:GET
- zz 李治国:地图大战本质是争抢O2O入口
- In Java, what is the default location for newly created files?
- 杭电 2047 阿牛的EOF牛肉串 (递推)
- hdu1161Eddy's mistakes
- Android 相对布局常用属性
- html5知识点:DOM编程
- nodeJS里面的模块
- 浏览器兼容CSS渐进增强 VS 优雅降级如何选择
- Python进阶:切片的误区与高级用法
- [转帖]csdn windows 下载整理.
- centos6.5配置redis服务 很好用谢谢
- 亿级 ELK 日志平台构建部署实践
- P2375 [NOI2014]动物园
- PAT-GPLT L1-033 - 出生年 - [简单模拟]
- ISO 8895-1
热门文章
- Ubuntu 下部署asp.net运行环境
- spring IOC源码分析(2)
- 10 Best Responsive HTML5 Frameworks and Tools
- javascript高级编程笔记03(正则表达式)
- Jfinal 入门
- Memcached(五)Memcached的并发实例
- HDU 1560 DNA sequence (IDA* 迭代加深 搜索)
- Bootstrap 貌似不错,先做一下记录
- TC Asia Competition
- Android ListView(Selector 背景图片)