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: 72% (11 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.
-
the sale of time to local, regional, and national advertisers?
-
Why might management wish to avoid reporting debt on the balance sheet?
-
Given that Dov Pharmaceuticals was down by 98 percent for 2006, why did some investors hold the stock? Why didnt they sell out before the price declined so sharply?
-
X Company has two production departments, A and B. The following is budgeted information for all of its products in 2019, and actual information for one of them, Product X: All Products Product X...
-
A spherical vessel used as a reactor for producing pharmaceuticals has a 5-mm-thick stainless steel wall (k = 17 W/m K) and an inner diameter of D j = 1.0 m. During production, the vessel is filled...
-
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...
-
Heat transfer in a gas can occur by a. radiation only b. convection only c. radiation and convection only d. radiation, convection, and conduction
-
An increase in the price and a decrease of the quantity of Paclitaxel (an anti-cancer drug) could be caused by which of the following? Select one: O a. an increase in the number of people being...
-
At December 31, 2023, Cord Company's plant asset and accumulated depreciation and amortization accounts had balances as follows: Category Land Land improvements Buildings Equipment Automobiles and...
-
Assume that the following table represents the sales figures for the five largest firms in the industry. Compute the HHI for the industry (assuming the industry contains just these five firms). Sales...
-
Case study: Sun City - improving operations performance to enhance guest experience 1. Describe how Sun City implements the five operations performance objectives or principles. 2. Using your...
-
What recommendations do you have to increase the likelihood of success? E.g., how would you reduce the likelihood of having to go back to A4? How would you reduce the impact of having to go back to...
-
When a tip was received that marijuana was being grown in his greenhouse, Michael Rileys property was observed from a helicopter by an investigating officer. The helicopter flyover was deemed...
-
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
-
Cover-to-Cover Company is a manufacturer of shelving for books. The company has compiled the following cost data, and wants your help in determining the cost behavior. After reviewing the data,...
-
Calculate the present value of cash flows, 1500 in the years 1, 2, and 3, then grows at 2% every year, using 10% discount rate. Round and write up to two decimals (e.g., 100.00). No characters...
-
Superman Enterprises has just completed an initial public offering. The firm sold 3,300,000 new shares (the primary offering). In addition, existing shareholders sold 275,000 shares (the secondary...
Study smarter with the SolutionInn App