没有小数点的计算器 [英] Calculator without a decimal point

查看:184
本文介绍了没有小数点的计算器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这最初只是一个没有小数点的计算器。添加小数后,它现在告诉我无效的第二个数字。

This was originally just a calculator without a decimal point. After I added the decimal, it now tells me invalid second number.


展开 | 选择 | Wrap | 行号

推荐答案

对不起德克萨斯州的迟到回复。您以前处理的是整数(没有小数点)。

要捕获整数,使用Integer.parseInt就足够了。添加小数点时,Integer.parseInt不再足够。您现在需要Double.parseDouble并将变量从int类型更改为double类型。我在下面做了这些更改。


Sorry Texas for the late reply. You were previously dealing with integers(without the decimal point).
To capture integers Integer.parseInt was used which was adequate. When you added the decimal point, Integer.parseInt was no longer sufficient. You now need Double.parseDouble and change your variables from int type to double type. I have made these changes below.


展开 | 选择 | Wrap | 行号


我不能相信它是那样的东西我忽略了特别感谢r035198x,不仅要查看代码,还要帮助我。
I cant believe that it was something that I overlooked. A special thanks to r035198x, for not only looking over the code, but for helping me out.



我不能相信它是某种东西我忽略了特别感谢r035198x,不仅要查看代码,还要帮助我。
I cant believe that it was something that I overlooked. A special thanks to r035198x, for not only looking over the code, but for helping me out.



只需发布您随时获得的任何Java问题。这里的人总是愿意提供帮助。

Just post any Java problems you get anytime. The guys here are always willing to help.


这篇关于没有小数点的计算器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆