Listing 3.5 gives a program to compute tax. Write a method for computing tax using the following
Question:
Listing 3.5 gives a program to compute tax. Write a method for computing tax using the following header:public static double?computeTax(int?status,?double?taxableIncome)Use this method to write a program that prints a tax table for taxable income from$50,000 to $60,000 with intervals of $50 for all the following statuses:
Transcribed Image Text:
Married Joint Тахable Single Married Head of or Qualifying Widow(er) Income Separate a House 6665 8688 50000 8688 7353 50050 8700 6673 8700 7365 9840 59950 11175 8158 11175 8165 9853 60000 11188 11188 Listing 1 import java.util.Scanner; 3 public class ComputeTax { public static void main(String[] args) { // Create a Scanner Scanner input - new Scanner(System.in); // Prompt the user to enter filing status System.out.print("(0-single filer, 1-married jointly or " "qualifying widow(er), 2-married separately, 3-head of " "household) Enter the filing status: "); 9. 10 11 12 13 14 15 int status - input.nextInt(); // Prompt the user to enter taxable income System.out.print("Enter the taxable income: "); double income - input.nextDouble(); 17 18 19 20 21 // Compute tax double tax - 0; 24 25 26 27 28 29 30 31 32 if (status == 0) { // Compute tax for single filers 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; el se tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35; 33 34 35 36 37 38 39 40 41 else if (status == 1) { // Left as an exercise // Compute tax for married file jointly or qualifying widow(er) 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 else if (status == 2) { // Compute tax for married separately // Left as an exercise else if (status =-- 3) { // Compute tax for head of household // Left as an exercise else { System.out.printIn("Error: invalid status"); System.exit(1); // Display the result System.out.printin("Tax is " + (int) (tax * 100) / 100.0); } 58 59 } Nm4 6708 Nm t 0700 9012N NNN NNNN NM
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 70% (10 reviews)
Program plan Step 1 Create a test class called ComputeTaxDemo ...View the full answer
Answered By
Anurag Agrawal
I am a highly enthusiastic person who likes to explain concepts in simplified language. Be it in my job role as a manager of 4 people or when I used to take classes for specially able kids at our university. I did this continuously for 3 years and my god, that was so fulfilling. Sometimes I've skipped my own classes just to teach these kids and help them get their fair share of opportunities, which they would have missed out on. This was the key driver for me during that time. But since I've joined my job I wasn't able to make time for my passion of teaching due to hectic schedules. But now I've made a commitment to teach for at least an hour a day.
I am highly proficient in school level math and science and reasonably good for college level. In addition to this I am especially interested in courses related to finance and economics. In quest to learn I recently gave the CFA level 1 in Dec 19, hopefully I'll clear it. Finger's crossed :)
4.80+
2+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Write a program to compute the following summation. 1 1 1 1 1 + V2 Vi + V3 V624 + V625 V3 + V4
-
Write a program to compute word ladders where single-character substitutions have a cost of 1, and single-character additions or deletions have a cost of p > 0, specified by the user. As mentioned at...
-
Listing 12.16, ReplaceText.java, gives a program that replaces text in a source file and saves the change into a new file. Revise the program to save the change into the original file. For example,...
-
Because export taxes on food commodities are frequently seen as falling on foreign consumers, they tend to be favored as revenue sources by many countries. What assumptions are necessary for export...
-
Show that if A is an infinite set, then whenever B is a set, A B is also an infinite set.
-
In a machine shop the average number of machines out of operation is two. Assuming a Poisson distribution for machines out of operation, calculate the probability that at any one time there will be:...
-
ZeeZee's Construction Company has the opportunity to select one of four projects (A, B, C, or D) or choose the null (do-nothing) alternative. Each project requires a single initial investment and has...
-
For each of the following scenarios, perform the three steps in the materiality process: (1) determine overall materiality, (2) determine tolerable misstatement, and (3) evaluate the audit findings....
-
You have been hired as a data analyst for the company. Adventure Works managers have requested that you analyze 3 years of sales and cost data to help them answer specific business questions. In the...
-
A single-phase motor takes 8.3 A at a power factor of 0.866 lagging when connected to a 230 V, 50 Hz supply. Two similar capacitors are connected in parallel with each other to form a capacitance...
-
Write a method that computes the commission, using the scheme in Programming Exercise 5.39 . The header of the method is as follows:public static double?computeCommission(double?salesAmount)Write a...
-
Write a method with the following header to format the integer with the specified width. public static String format(int number, int width) The method returns a string for the number with one or more...
-
Write an application that uses String method region-Matches to compare two strings input by the user. The application should input the number of characters to be compared and the starting index of...
-
What is the consequence if a mutual funds fails to meet one of the diversification rules?
-
There are multiple forms of business reports utilized both internally and externally. From your readings and experience, what two reports are common internally? What two reports are common externally?
-
5 years ago, you paid $1065 for a $1,000 par bond that has a 7% coupon with semiannual payments. You are selling it today for $976. You reinvested coupons at the 4% annual rate. What is your total...
-
Recently, Macy's announced the combined closing of over 125 stores and the layoff of approximately 2,000 workers nationwide. Do some research on Macy's. Visit IBISWorld and research the U.S....
-
Many would say that poverty is a financial issue and of course it is but if it were only that then all the charity and aid would have made a difference by now both with domestic poverty and...
-
What is the audit expectations gap and how can it be reduced?
-
The Heese Restaurant Group manufactures the bags of frozen French fries used at its franchised restaurants. Last week, Heeses purchased and used 101,000 pounds of potatoes at a price of $ 0.70 per...
-
If j = 5 and k = 6, then the value of j++ == k is ____________. a. 5 b. 6 c. True d. False
-
You must always include ____________ in a for loops parentheses. a. Two semicolons b. Three semicolons c. Two commas d. Three commas
-
What does the following statement output? for(a = 0; a < 5; ++a) System.out.print(a + " "); a. 0 0 0 0 0 b. 0 1 2 3 4 c. 0 1 2 3 4 5 d. Nothing
-
1. There is a project with the following cash flows: Year 0 Cash Flow -$23,400 2345 6,800 7,900 7,000 7,600 6,400 What is the payback period? You must show all your work to earn credits. 2. Filter...
-
What is the difference between net present value and internal rate of return? Explain briefly
-
Donkey Haven is located in Australia. Donkey Haven offers 16 acres of treed rural farmland, for guests to explore and enjoy. Guests can sit outside, listening to the wind in the trees, admire the...
Study smarter with the SolutionInn App