Write a Java program that computes the amount of income tax that a person must p
ID: 3536811 • Letter: W
Question
Write a Java program that computes the amount of income tax that a person must pay, depending upon salary. Income tax should be calculated for each portion of income in each range. For example, a user who earns $25,000.0 pays 10% on the first $7,825.0 and 15% on the remaining $17,175.0. Your program should use the following income tax guidelines for income tax calculations:
Income Ranges Tax Rate
<= $7,825.00 10%
>$7,825.00 to <= $31,850.00 15%
>$31,850.00 to <= $77,100.00 25%
>$77,100.00 to <= $160,850.00 28%
>$160,850.00 to <= $349,700.00 33%
> $349,700.00 35%
You need to use a nested-if statement to help make decisions for this program.
Explanation / Answer
Sample output
I am the Income Tax Calculator
Enter the amount of money You earn
25000
Your total payable tax is $3358.75
public class IncomeTax {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("I am the Income Tax Calculator");
System.out.println("Enter the amount of money You earn");
double amount = scanner.nextDouble();
IncomeTax incomeTax = new IncomeTax();
double tax = incomeTax.calculateTax(amount);
System.out.println("Your total payable tax is $"+ tax);
}
public double calculateTax(double amount)
{double tax = 0;
if (amount <= 7825.00)
{
tax = 0.10 * amount;
}
else if (amount > 7825.00 && amount <= 31850.00)
{
amount = amount- 7825.00;
tax = (0.10 * 7825.00) + (0.15 * amount);
}
else if (amount > 31850.00 && amount <= 77100.00)
{
amount = amount- 31850.00;
tax = (0.10 * 7825.00) + (0.15 * 24025.00) + (0.25 * amount);
}
else if (amount > 77100.00 && amount <= 160850.00 )
{
amount = amount- 77100.00;
tax = (0.10 * 7825.00) + (0.15 * 24025.00) + (0.25 * 45250.00 ) + (0.28 * amount);
}
else if (amount > 160850.00 && amount <= 349700.00 )
{
amount = amount- 160850.00 ;
tax = (0.10 * 7825.00) + (0.15 * 24025.00) + (0.25 * 45250.00 ) + (0.28 * 83750.00) + (0.33 * amount);
}
else if ( amount > 349700.00)
{
amount = amount- 349700.00 ;
tax = (0.10 * 7825.00) + (0.15 * 24025.00) + (0.25 * 45250.00 ) + (0.28 * 83750.00) + (0.33 * 188850.00) + (0.35 * amount);
}
return tax;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.