can someone help me? 1. Write a static method named tax that accepts a salary as
ID: 3654729 • Letter: C
Question
can someone help me? 1. Write a static method named tax that accepts a salary as a parameter and that returns the amount of federal tax you would owe if you make that salary. The tax is computed based on your tax bracket as found from the first two columns below. Once you know which row of the table to use, start with the "flat amount" and add the "plus %" of the amount over the amount listed in the final column. For example, if your income is $50,000, then you use the third row of the table and compute the tax as $4,000 plus 25% of the amount over $29,050, which comes to $9,237.50. The total tax on $27,500 is $3,767.50. For $6,000, the tax is $600. For $120,000, the tax is $28,227. over but not over flat amount plus % of excess over $0 $7,150 $0 10% $0 $7,150 $29,050 $715 15% $7,150 $29,050 $70,350 $4,000 25% $29,050 $70,350 unlimited $14,325 28% $70,350 You may assume that your method is passed a value greater than or equal to 0. Finish the following code file: public class TestTax { public static void main(String[] args) { System.out.println("The tax on $50000 is " + tax(50000)); // 9237.5 System.out.println("The tax on $27500 is " + tax(27500)); // 3767.5 System.out.println("The tax on $6000 is " + tax(6000)); // 600.0 System.out.println("The tax on $120000 is " + tax(120000)); // 28227.0 }Explanation / Answer
public class TestTax { public static void main(String[] args) { System.out.println("The tax on $50000 is " + tax(50000)); // 9237.5 System.out.println("The tax on $27500 is " + tax(27500)); // 3767.5 System.out.println("The tax on $6000 is " + tax(6000)); // 600.0 System.out.println("The tax on $120000 is " + tax(120000)); // 28227.0 } // your code goes here public static Double tax(int salaryIn) { Double salary = new Double(salaryIn); if (salary < 7150.0) { return salary * 0.1; } if (salary < 29050.0) { return 715.0 + (salary - 7150.0) * 0.15; } if (salary < 70350.0) { return 4000.0 + (salary - 29050.0) * 0.25; } return 14325.0 + (salary - 70350.0) * 0.28; } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.