올바른 코드를 올바르게 출력하는 방법을 잘 모르겠습니다. 여기에 내가 무엇을 가지고 지금까지Java 변수가 초기화되지 않았을 수 있습니다.
import java.util.Scanner;
public class ComputeTax {
public static void main(String[] args) {
System.out.print("Taxable Income Single Married Jointly Married Seperate Head of House");
System.out.print("\n\n-----------------------------------------------------------------------------------");
int status;
double income;
double tax = 0;
for(income = 50000; income <= 60000; income+=50)
{
if (status == 50000)
{
if (income <= 8350)
tax = income * 0.10;
else if (income <= 33950)
tax = 8350 * 0.10 + (income - 8350) * 0.15;
else if (income <= 82250)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(income - 33950) * 0.25;
else if (income <= 171550)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (income - 82250) * 0.28;
else if (income <= 372950)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(income - 171550) * 0.33;
else
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}
else if (status == 1) { // Compute tax for married file jointly
// Left as exercise
}
else if (status == 2) { // Compute tax for married separately
// Left as exercise
}
else if (status == 3) { // Compute tax for head of household
// Left as exercise
}
// Display the result
System.out.println("Tax is " + (int)(tax * 100)/100.0);
}
}
}
샘플 출력은 다음과 같습니다
Taxable Income Single Married Married Seperate Head of House
50000 8688 6665 8688 7352
50050 8700 6673 8700 7365
...
59950 11175 8158 11175 9840
60000 11188 8165 11188 9852
나는 나의 "루프"난 그냥 내 계산에 대해 확실하지 오전 그들 모두를 인쇄하는 방법을 정확 생각 . 현재, 오류가 발생합니다 :
무엇이 질문입니까? 현재 산출물의 예를 들려 줄 수 있습니까? –
변수 상태가 초기화되지 않았 음을 나타내는 "if 문"으로 인해 오류가 발생했습니다 – Tanner10
@ Tanner10 Google에서 첫 번째 링크가 "java 초기화되지 않았습니다."http://stackoverflow.com/questions/2448843/variable- 초기화되지 않은 오류 – sashkello