如何添加不同货币的硬币
我们正在教授一门需要教授货币知识的课程。我们希望我们的学生使用世界各地的不同货币进行添加和演示。
(e.g. Country=US, How much does 3 nickels + 2 pennies + 3 dimes)
(e.g. Country=UK, ...)
(e.g. Country=JAPAN, ...)
(e.g. Country=CHINA, ....)
(e.g. Country=AUSTRALIA, ...)
有没有示例代码可以演示不同货币的硬币转换?
注意:如果它还包含较小单位之间的转换(例如黑白镍币、便士、一角硬币、美元),它将很有用。
We are teaching a class where we need to teach about currency. We would like our students to add and demonstrate using different currencies across the world.
(e.g. Country=US, How much does 3 nickels + 2 pennies + 3 dimes)
(e.g. Country=UK, ...)
(e.g. Country=JAPAN, ...)
(e.g. Country=CHINA, ....)
(e.g. Country=AUSTRALIA, ...)
Is there any sample code, which demonstrates conversion of coins in different currencies?
Note: If it also contains the conversion between smaller units (e.g. b/w nickels, pennies, dimes, dollar) it would be useful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Java 枚举是一个很好的工具。您可以为每种货币创建一个:
此代码显示了如何使用它:
Java enumerations are a nice tool. You can create one for each currency:
This code shows how to use it: