Java十进制格式问题? [英] Java decimal format question?

查看:163
本文介绍了Java十进制格式问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在制作披萨计算器,但我的结果是7.5美元,而不是7.50美元。我有这个十进制格式的代码写在我的代码下面,但它似乎没有做任何事情。



有人可以帮助我吗?



我尝试过:



DecimalFormat x = newDecimalFormat(0.00) ;

costOutput.setText(披萨的成本是$+ totalCost);

解决方案

7.5而不是


7.50。我的代码下面写了这个十进制格式代码,但它似乎没有做任何事情。



有人可以帮帮我吗?



我尝试了什么:



DecimalFormat x = newDecimalFormat(0.00);

costOutput.setText(披萨的成本是


+ totalCost);

Hello, I am making a pizza calculator but my results come out as "$7.5" and not "$7.50". I have this decimal format code written out with my code below it, but it doesn't seem to be doing anything.

can someone please help me?

What I have tried:

DecimalFormat x = newDecimalFormat("0.00");
costOutput.setText("The cost of the pizza is $" + totalCost);

解决方案

7.5" and not "


7.50". I have this decimal format code written out with my code below it, but it doesn't seem to be doing anything.

can someone please help me?

What I have tried:

DecimalFormat x = newDecimalFormat("0.00");
costOutput.setText("The cost of the pizza is


" + totalCost);


这篇关于Java十进制格式问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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