import javax.swing.JOptionPane;
/*Download by http://www.codefans.net*/
public class ComputeChange {
/** Main method */
public static void main(String[] args) {
// Receive the amount entered from the keyboard
String amountString = JOptionPane.showInputDialog(
"Enter an amount in double, for example 11.56");
// Convert string to double
double amount = Double.parseDouble(amountString);
int remainingAmount = (int) (amount * 100);
// Find the number of one dollars
int numberOfOneDollars = remainingAmount / 100;
remainingAmount = remainingAmount % 100;
// Find the number of quarters in the remaining amount
int numberOfQuarters = remainingAmount / 25;
remainingAmount = remainingAmount % 25;
// Find the number of dimes in the remaining amount
int numberOfDimes = remainingAmount / 10;
remainingAmount = remainingAmount % 10;
// Find the number of nickels in the remaining amount
int numberOfNickels = remainingAmount / 5;
remainingAmount = remainingAmount % 5;
// Find the number of pennies in the remaining amount
int numberOfPennies = remainingAmount;
// Display results
String output = "Your amount " + amount + " consists of \n"
+ numberOfOneDollars + " dollars\n"
+ numberOfQuarters + " quarters\n"
+ numberOfDimes + " dimes\n"
+ numberOfNickels + " nickels\n"
+ numberOfPennies + " pennies";
JOptionPane.showMessageDialog(null, output);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Java-data.rar_java data
共35个文件
class:17个
java:16个
project:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 36 浏览量
2022-09-19
18:23:13
上传
评论
收藏 21KB RAR 举报
温馨提示
java数据结构基本结构的实现及其应用,适合初学者学习
资源推荐
资源详情
资源评论
收起资源包目录
Java-data.rar (35个子文件)
Java基本数据类型及操作相关实例
bin
DisplayTime.class 986B
FahrenheitToCelsius.class 910B
DisplayUnicode.class 568B
ComputeChange.class 2KB
ComputeArea.class 869B
ComputeLoan.class 2KB
ShowCurrentTime.class 1KB
ComputeLoanAlternative.class 2KB
IntegerDemo.class 853B
DoubleDemo.class 1KB
SaleTax.class 602B
TestScanner.class 1KB
ShowSyntaxErrors.class 391B
ShowRuntimeErrors.class 751B
ShowLogicErrors.class 760B
ComputeAreaConst.class 910B
src
DisplayUnicode.java 211B
ComputeChange.java 2KB
ShowCurrentTime.java 1KB
ComputeArea.java 351B
DisplayTime.java 400B
ComputeLoan.java 1KB
ComputeAreaConst.java 421B
DoubleDemo.java 606B
SaleTax.java 226B
ComputeLoanAlternative.class 2KB
ShowSyntaxErrors.java 202B
ComputeLoanAlternative.java 1KB
ShowRuntimeErrors.java 317B
IntegerDemo.java 402B
FahrenheitToCelsius.java 309B
TestScanner.java 732B
ShowLogicErrors.java 222B
.project 380B
.classpath 232B
共 35 条
- 1
资源评论
Kinonoyomeo
- 粉丝: 75
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功