【发布时间】:2014-03-02 23:51:33
【问题描述】:
我正在尝试制作的程序需要在程序运行后将双倍“收入”设置为小数点后 2 位。
下面显示了我设置的方式,但是在我运行程序之后,它仍然要么掉零要么结束。可能是什么问题?
println("Please enter your filing status");
println("Enter 0 for single filers,");
println(" 1 for married filing jointly,");
println(" 2 for married filing seperately,");
println(" 3 for head of household");
int status = readInt("Status: ");
double income = readDouble("Please enter your taxable income: ");
DecimalFormat df = new DecimalFormat("#.00");
System.out.print(df.format(income));
if ((status == 0) && (income <= SINGLE_BRACKET1))
{
println("You owe: $" + (income * .1));
}
else if ((status == 0) && (income <= SINGLE_BRACKET2))
{
println("You owe: $" + ((SINGLE_BRACKET1 * .1) +
(income - SINGLE_BRACKET1) * .15));
}
【问题讨论】:
标签: java decimal decimalformat