Can someone attempt to do the extra credit also thank you very much!! Objective
ID: 3747105 • Letter: C
Question
Can someone attempt to do the extra credit also thank you very much!!
Objective
The purpose of this assignment is to test your familiarity with Java I/O statements and
if-else statements. This assignment also tests your understanding of the basics of Java
programming and execution, like top-down control flows, translating the logical solution
to a problem into code, and integrating the new concepts you just learned with the
older concepts, including data types and variables, declaration, initialization and
assignments, arithmetic operators, etc.
Please submit your source code (i.e. your java file) on Canvas under HW1.
Problem
It’s the year 2030 and H&R Block is facing a software crisis! Tax season is coming up in a few
months, and their current tax solution is not compatible with the new rules that the IRS has
imposed. They have hired you as a software engineer to program their new system. Your task is
to calculate the income tax a person owes to the IRS. To do so you can use the following table
Tax Bracket Annual Income Tax Owed to the IRS
1 Under $10,000 $0
2 $10,000 - $24,999 15 % of the annual
income
3 $25,000 - $74,999 $3,750 + 20% of the
amount exceeding
$25,000
4 $75,000 - $149,999 $15,000 + 25% of the
amount exceeding
$75,000
5 $150,000 - $299,999 $37,500 + 30% of the
amount exceeding
$150,000
6 Above $300,000 $45,000 + 35% of the
amount exceeding
$300,000
Your program should take as input, the annual income of a user and print the tax bracket and
total tax owed to the IRS. You may round your answers to 2 decimal places.
Sample Run 1
Please enter your annual income ($): $66700
*************************************
Your tax bracket is 3
Total taxes owed to the IRS: $12090.00
************************************
Sample Run 2
Please enter your annual income ($): $16200
*************************************
Your tax bracket is 2
Total taxes owed to the IRS: $2430.00
************************************
Extra Credit (10 points)
Please note, if you are going to attempt this, make sure you submit a version of your original
solution (without the extra credit part) as well.
You should modify your code, to compute / take into account 2 things.
1. Each individual is allowed to claim a standard deduction of upto $12,000, on top of the
annual income he/she earns. You can assume the user will always want to claim this tax
break.
2. You should compute and output the tax refund the user will get in 2030. To do this you
must also input the amount of taxes the user has already paid to the IRS along with
his/her annual income. Then you may calculate the refund by subtracting the taxes
owed to the IRS from the taxes paid to the IRS. If the taxes owed is greater than the
taxes paid, then the program should inform the user that he/she owes money to the
IRS.
Sample Run 3 (this includes the standard deduction computation)
Please enter your annual income ($): 216200
Please enter your taxes paid to the IRS: 82345
*************************************
Your tax bracket is 5
Total taxes owed to the IRS: $53760
Your tax refund is: $28585
************************************
Sample Run 4 (this includes the standard deduction computation)
Please enter your annual income ($): 216200
Please enter your taxes paid to the IRS: 22345
*************************************
Your tax bracket is 5
Total taxes owed to the IRS: $53760
You owe money to the IRS: $31415
************************************
CODE to the answer I need help with the extra credit part.
Explanation / Answer
TaxCalculator.java
import java.util.Scanner;
public class TaxCalculator {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Please enter your annual income ($): ");
double income = in.nextDouble();
System.out.print("Please enter your taxes paid to the IRS: ");
double taxesPaid = in.nextDouble();
System.out.println(" *************************************");
int taxBracket = 0;
double taxes = 0;
if(income < 10000) {
taxBracket = 1;
taxes = 0;
} else if(income < 25000) {
taxBracket = 2;
taxes = 0.15 * income;
} else if(income < 75000) {
taxBracket = 3;
taxes = 3750 + 0.20 * (income - 25000);
} else if(income < 150000) {
taxBracket = 4;
income-=12000;
taxes = 15000 + 0.25 * (income - 75000);
} else if(income < 300000) {
taxBracket = 5;
income-=12000;
taxes = 37500 + 0.30 * (income - 150000);
} else {
taxBracket = 6;
income-=12000;
taxes = 45000 + 0.35 * (income - 300000);
}
System.out.println("*************************************");
System.out.println("your tax bracket is " + taxBracket);
System.out.println("Your taxes owed to the IRS is :$" + taxes);
double refund = taxes - taxesPaid;
if(taxes<= taxesPaid) {
System.out.println("Your tax refund is: " + Math.abs(refund));
} else {
System.out.println("You owe money to the IRS: $" + Math.abs(refund));
}
System.out.println("*************************************");
in.close();
}
}
________________
Output#1:
Please enter your annual income ($): 216200
Please enter your taxes paid to the IRS: 82345
*************************************
*************************************
your tax bracket is 5
Your taxes owed to the IRS is :$53760.0
Your tax refund is: 28585.0
*************************************
Output#2:
Please enter your annual income ($): 216200
Please enter your taxes paid to the IRS: 22345
*************************************
*************************************
your tax bracket is 5
Your taxes owed to the IRS is :$53760.0
You owe money to the IRS: $31415.0
*************************************
____________Thank You