我試圖製作的程序需要在程序運行後將雙「收入」設置爲2個小數位。
下面顯示了我設置的方式,但在運行程序後,它仍然會降低零點或結束。可能是什麼問題呢?如何將程序的DecimalFormat設置爲Java中的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));
}
現在它告訴不相容類型的高亮顯示()的getInstance之後的任何想法 – user3361101
請參閱編輯 – hd1