Listing 3.5, ComputeTax.java, gives the source code to compute taxes for single filers. Complete Listing 3.5 to
Question:
Listing 3.5, ComputeTax.java, gives the source code to compute taxes for single filers. Complete Listing 3.5 to compute the taxes for all filing statuses.
Listing 3.5
Transcribed Image Text:
1 import java.util.Scanner; 3 public class ComputeTax { public static void main(String] args) { 4 // Create a Scanner Scanner input - new Scanner (System.in); 5 // 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: "); 10 11 12 int status - input.nextInt(); 13 14 15 16 17 18 19 20 21 22 23 // Prompt the user to enter taxable income System.out.print("Enter the taxable income: "); double income - input.nextDouble(); // Compute tax double tax - 0; 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; 24 25 26 27 28 29 30 31 32 33 else if (income <= 372950) tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (income - 171550) * 0.33; else tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35; 34 36 37 38 40 41 42 43 44 else if (status -- 1) { // Left as an exercise // Compute tax for married file jointly or qualifying widow(er) else if (status -- 2) { // Compute tax for married separately // Left as an exercise 46 47 48 else if (status =- 3) { // Compute tax for head of household // Left as an exercise else { System.out.print1n("Error: invalid status"); System.exit(1); // Display the result System.out.printIn("Tax is " + (int)(tax * 100) / 100.0); 59 } 1234S67 00 (0-single filer, 1-married jointly or qualifying widow(er), 2-married separately, 3-head of household) Enter the filing status: 0 ercer Enter the taxable income: 400000 |Ptrter Tax is 117683.5 line# status income tax output 13 17 400000 20 38 117683.5 57 Tax is 117683.5
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 58% (12 reviews)
To generate the tax depending upon the entered status of teh user ...View the full answer
Answered By
Muhammad Umair
I have done job as Embedded System Engineer for just four months but after it i have decided to open my own lab and to work on projects that i can launch my own product in market. I work on different softwares like Proteus, Mikroc to program Embedded Systems. My basic work is on Embedded Systems. I have skills in Autocad, Proteus, C++, C programming and i love to share these skills to other to enhance my knowledge too.
3.50+
1+ 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 that converts the Java source code from the next-line brace style to the end-of-line brace style. For example, the following Java source in (a) uses the next-line brace style. Your...
-
Revise the program in Listing 21.7. If a keyword is in a comment or in a string, don?t count it. Pass the Java file name from the command line. Assume that the Java source code is correct and line...
-
Rewrite Listing 21.7 CountKeywords. java to read in a Java source code file and count the occurrence of each keyword in the file, but don?t count the keyword if it is in a comment or in a string...
-
In MySQL, Useing ClassicModels database below, how do I script it to display ProductLine total_sales by region like this; a. Region-1 i. Productline-1 ---- Total Sales ii. Productline-2 ---- Total...
-
Refer to Figure 24(B). Compute cosÏ, sin Ï, cot Ï, and cscÏ. 0.3 FIGURE 24
-
What is the AMAT for P1 and P2? In this exercise, we will look at the different ways capacity affects overall performance. In general, cache access time is proportional to capacity. Assume that main...
-
Consider the following cash flow profile and assume MARR is 10 percent/year. a. What does Descartes' rule of signs tell us about the IRR(s) of this project? b. What does Norstrom's criterion tell us...
-
The three accounts shown below appear in the general ledger of Chaudry Corp. during 2014. Instructions From the postings in the accounts, indicate how the information is reported on a statement of...
-
23. If an item retails for $320 after being marked up by 85%, what was the dollar amount of the cost?
-
The energy gap of an element is given as 5.9x10 ev. Calculate the intrinsic coherent length if V; = 5.82x10 m/s. (a) 5.9 pm (b) 1.2 m (c) 9.5 m ( d) 2.1 m
-
Write a program that prompts the user to enter a three-digit integer and determines whether it is a palindrome number. A number is palindrome if it reads the same from right to left and from left to...
-
Write a program that lets the user guess whether the flip of a coin results in heads or tails. The program randomly generates an integer 0 or 1, which represents head or tail. The program prompts the...
-
Why can it generally be assumed that the supply curve for the airline industry is relatively inelastic?
-
Given the function (x) = x + x 10x, find all x-values where f has an inflection point.
-
Short-term Liquidity- Calculate the following: a) Days Inventory Held (also known as "Days Inventory") b) Days Sales Outstanding (also known as "Days Receivables") c) Days Payable Outstanding (also...
-
OAB company intends to distribute dividends to its stockholders amounting to BD12 per share next year. The amount represents 15% return of investors money. However, the company as part of its...
-
Suppose the project requires initial investment of $10000 and expects to receive annual end-of-year perpetual payments. The first payment is estimated to be $872 and we expect the payment to grow at...
-
What is the 1year futures value for a stock with spot price of $200. Assume the one-year T-bill rate is 3% and dividend yield is 2%. All the rates are continuously compounded. If possible, conduct an...
-
Winter Sportswear Inc. reported the following in its December 31, 2014, fi nancial statements. 2014 2013 Inventory...............................$55,600........$50,000 Accounts...
-
Refer to Exercise 8.S.I. Construct a scatterplot of the data. Does the appearance of the scatterplot indicate that the pairing was effective? Explain. Exercise 8.S.I. A volunteer working at an animal...
-
Modify Listing 18.8, TowerOfHanoi.java, so the program finds the number of moves needed to move n disks from tower A to tower B. (Hint: Use a static variable and increment it every time the method is...
-
The text presented the Sierpinski triangle fractal. In this exercise, you will write a program to display another fractal, called the Koch snowflake, named after a famous Swedish mathematician. A...
-
Write a program that prompts the user to enter a directory and displays the number of the files in the directory.
-
1. Consider the following pseudocode. What does it produce? Set a = 0 Set b = 0 Set c = 1 Set d = 1 Report the value of d Repeat until a equals 10 Set d = b + c Set b = c Set c = d Add 1 to a Report...
-
3. It has been observed that a particular plant's growth is directly proportional to time. It measured 2 cm when it arrived at the nursery and 2.5 cm exactly one week later. If the plant continues to...
-
List four equivalent forms for the rational expression. x-2 x+9
Study smarter with the SolutionInn App