Question

File Edit View Windew Help ⑦ A Sign In Home Tools IT109N Assigmenx Share By completing this assignment, students should be ab

File Edit View Windew Help ⑦ A Sign In Home Tools IT109N Assigmenx 也Share Soarch tools You are to write a program to compute

import java.util.*; //Include the needed package

public class IncomeTax //Class
{
public static void main(String[] args)
{

Scanner scInput = new Scanner(System.in); //Create new instance
  
System.out.println("\nEnter the filing status"); //Prompt for input
System.out.println("\0 for filling as single. ");
System.out.println("\1 for filling as married jointly. ");
System.out.println("\2 for filling as married separately. ");
System.out.println("\3 for filling as head of household. ");

int filingStatus = scInput.nextInt();

System.out.println("Enter the taxable income:");

double ti = scInput.nextDouble();

double it = 00.00;

if(filingStatus==0)
{
if (ti<=8350)

it=ti*0.10;

else if (ti <= 82250)

it=8350*0.10+(33950-8350)*0.15+(ti-33950)*0.25;

else if (ti<=171550)

it=8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(ti-82250)*0.28;

else if(ti<372950)

it=8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(171550-82250)*0.28+(ti-171550)*0.33;
  
else
it=8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(171550-82250)*0.28+(372950-171550)*0.33+(ti-372950)*0.35;
}

else if (filingStatus==1) //Check condition for married filling jointly
{
if (ti<=16700)
it=ti*0.10;
  
else if (ti<=67900)
it = 16700*0.10+(ti-16700)*0.15;

else if (ti<=137050)
it=16700*0.10+(67900-16700)*0.15+(ti-67900)*0.25;

else if (ti<=208850)
it=16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(ti-137050)*0.28;

else if (ti<=372950)
it=16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(208850-137050)*0.28+(ti-208850)*0.33;

else
it=16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(208850-137050)*0.28+(372950-208850)*0.33+(ti-372950)*0.35;
}

else if (filingStatus==2) //Checking condition for married filing seperately
{
if (ti<=8350)
it=ti*0.10;

else if (ti<=33950)
it=8350*0.10+(ti-8350)*0.15;

else if (ti<=68525)
it=8350*0.10+(33950-8350)*0.15+(ti-33950)*0.25;

else if (ti<=104425)
it=8350*0.10+(33950-8350)*0.15+(68525-33950)*0.25+(ti-68525)*0.28;

else if (ti<=186475)
it=8350*0.10+(33950-8350)*0.15+(68525-33950)*0.25+(104425-68525)*0.28+(ti-104425)*0.33;

else
it=8350*0.10+(33950-8350)*0.15+(68525-33950)*0.25+(104425-68525)*0.28+(186475-171550)*0.33+(ti-372950)*0.35;
}

else if (filingStatus==3) //Checking condition for head of household
{
if (ti<=11950)
it= ti*0.10;
  
else if (ti<=45500)
it=11950*0.10+(ti-11950)*0.15;

else if (ti<=117450)
it=11950*0.10+(45500-11950)*0.15+(ti-45500)*0.25;

else if (ti<=171550)
it=11950*0.10+(45500-11950)*0.15+(117450-45500)*0.25+(ti-117450)*0.28;

else if (ti<=372950)
it=11950*0.10+(45500-11950)*0.15+(117450-45500)*0.25+(171550-117450)*0.28+(ti-171550)*0.33;

else
it=11950*0.10+(45500-11950)*0.15+(117450-45500)*0.25+(171550-117450)*0.28+(372950-171550)*0.33+(ti-372950)*0.35;
}

else
{
System.out.println("Invalid filing status");
}
  
System.out.println("Tax is : " + (int)(it * 100)/100.);
}
}

I have done the code

when I test run the code the sample one was a success and same as the picture but sample 2,3,4 was not same as the picture

pls find the error in the code and reply asap
  

File Edit View Windew Help ⑦ A Sign In Home Tools IT109N Assigmenx Share By completing this assignment, students should be able to: Soarch tools Assign expressions to variables Performi arithrietic calculations using Java Faport PD Implement console user input/output in their programs . Use If-else statements to cantrol the flow of logic in a program Create POF O-Edit PDF Comment Computing Tax ECombine Files The United States federal personal income tax is calculated based on filing status and taxable income E Organize Pages There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. he tax rates vary every year. Table 1 shows the rates for 2009. If you are, say, single with a Redact taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%. So, your tax is $1,082.50 Protect Table 1 Optimize PDF 2009 U.S. Federal Personal Tox Rotes Fill&sig Married FilingJnlyarried Filing arginal r Qualified Widow(er) aSend for Review Head of Household ax Rate More Tools $0-$16,700 50 $8,350 50 -$11,95%0 - 58,350 $16,701-$67,900 351-$33,950 11,951- $15,500 5% 351-533,950 33,951 $82,250 $67,901-$137,050 3,951- $68,525 $45,501-$117,450 5% 2,251 $171,550 $137,051-$208,85068,526- $104,425 $117,451 $190,200 171,551- $372,950 $208,851 -$372,950 $104,426- $186,475 $190,201 $372,950 33% 372,951+ Conert and edit 372,951+ 372,951 $186,476+
File Edit View Windew Help ⑦ A Sign In Home Tools IT109N Assigmenx 也Share Soarch tools You are to write a program to compute personal income tax. Your program should prompt the user to Faport PD enter the filing status and taxable income and compute the tax. Enter for single filers, 1 for married filing jointly, 2 for married filing separately, and 3 far head of household Create POF o-Edit PDF Here are sample runs of the program: Comment Sample 1 ECombine Files Enter the 11ina status : 印Organize Pages Entor tho taxable incomo: 100000 Tax is 21720.0 Redact Protect Sample 2: Optimize PDF Enter the ilinc status: 1 Enter the taxable income: 300339 Fill&sig Tax is 76932.87 aSend for Review More Tools Sample 3: Enter the riling status: 2 Enter the taxable income: 123500 Tax is 29665.S Sample 4 EnLe Lhe iling sLaLus 3 Enter the taxable income: 545402 Tax is 1565251 Conert and edit POF E/2019
0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Modified code

solution

import java.util.* //Include the needed package public class IncomeTax //Class public static void main (String[] args) Scanneit-ti*0.10; else if (ti 33950) it8350 0.10+(ti-8350)+0.15; else if (ti < 82250) it 8350 0.10+ (33950-8350) *0.15 (ti-33950) *else if (ti< 67900) it 16700 0.10+(ti-16700) *0.15; else if (ti 137050) it-16700*0.10+ (67900-16700) +0.15+ (ti-67900) *0.25;else if (ti<=104425) it-8350 0.10+ (33950-8350)0.15+ (68525-33950)*0.25+(ti- 68525) +0.28; else if (ti 186475) it=8 3 50+0.10else if (ti <=372950) it= 11950+0.10 (45500-11950)*0.15 +(117450-45500)+0.25 + + (190200 -117450) 0.28 +(ti - 190200)0.33; el

//output

javac IncomeTax.java java IncomeTax nter the filing status for filing as single for filing as married jointly for filing as m

Enter the filing status for filing as single 1 for filing as married jointly. 2 for filing as married separately. for filing

//copyable code

import java.util.*; //Include the needed package

public class IncomeTax //Class

{

public static void main(String[] args)

{

Scanner scInput = new Scanner(System.in); //Create new instance

//Prompt for input

         System.out.println("\nEnter the filing status");

         System.out.println("\n 0 for filing as single.");

         System.out.println("\n 1 for filing as married jointly.");

         System.out.println("\n 2 for filing as married separately.");

         System.out.println("\n 3 for filing as head of household.");

int filingStatus = scInput.nextInt();

System.out.println("Enter the itable income:");

double ti = scInput.nextDouble();

double it = 00.00;

if(filingStatus==0)

{

if (ti<=8350)

it=ti*0.10;

else if (ti <= 33950)

               

it = 8350*0.10+(ti-8350)*0.15;

           

else if (ti <= 82250)

it=8350*0.10+(33950-8350)*0.15+(ti-33950)*0.25;

else if (ti<=171550)

it=8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(ti-82250)*0.28;

else if(ti<=372950)

it=8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(171550-82250)*0.28+(ti-171550)*0.33;

else

it=8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(171550-82250)*0.28+(372950-171550)*0.33+(ti-372950)*0.35;

}

else if (filingStatus==1) //Check condition for married filling jointly

{

if (ti<=16700)

it=ti*0.10;

else if (ti<=67900)

it = 16700*0.10+(ti-16700)*0.15;

else if (ti<=137050)

it=16700*0.10+(67900-16700)*0.15+(ti-67900)*0.25;

else if (ti<=208850)

it=16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(ti-137050)*0.28;

else if (ti<=372950)

it=16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(208850-137050)*0.28+(ti-208850)*0.33;

else

it=16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(208850-137050)*0.28+(372950-208850)*0.33+(ti-372950)*0.35;

}

else if (filingStatus==2) //Checking condition for married filing seperately

{

if (ti<=8350)

it=ti*0.10;

else if (ti<=33950)

it=8350*0.10+(ti-8350)*0.15;

else if (ti<=68525)

it=8350*0.10+(33950-8350)*0.15+(ti-33950)*0.25;

else if (ti<=104425)

it=8350*0.10+(33950-8350)*0.15+(68525-33950)*0.25+(ti-68525)*0.28;

else if (ti<=186475)

it=8350*0.10+(33950-8350)*0.15+(68525-33950)*0.25+(104425-68525)*0.28+(ti-104425)*0.33;

else

it=8350*0.10+(33950-8350)*0.15+(68525-33950)*0.25+(104425-68525)*0.28+(186475-171550)*0.33+(ti-372950)*0.35;

}

else if (filingStatus == 3) {

if (ti>=0 & ti <= 11950)

it = ti * 0.10;

else if (ti <= 45500)

it = 11950*0.10 + (ti - 11950)*0.15;

else if (ti <= 117450)

it = 11950*0.10 + (45500 - 11950)*0.15 +(ti - 45500) * 0.25;

else if (ti <= 190200)

it = 11950*0.10 + (45500 - 11950)*0.15 +(117450 - 45500)*0.25 + (ti - 117450)*0.28;

else if (ti <= 372950)

it = 11950*0.10 + (45500 - 11950)*0.15 +(117450 - 45500)*0.25 + (190200 - 117450)*0.28 +(ti - 190200) * 0.33;

else

it = 11950*0.10 + (45500 - 11950)*0.15 +(117450 - 45500)*0.25 + (190200 - 117450)*0.28 +(372950 - 190200)*0.33 + (ti - 372950)*0.35;

}

else

{

System.out.println("Invalid filing status");

}

System.out.println("tax is : " + (int)(it * 100)/100.0);

}

}

Add a comment
Know the answer?
Add Answer to:
import java.util.*; //Include the needed package public class IncomeTax //Class { public static void main(String[] arg...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT