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
-
Has your organization used a team-based approach in its attempt to improve productivity? If Yes, was the approach successful? Why? What was the experience? If No, what was standing in the way of your...
-
In what ways could you improve how you deliver or make use of practice development sessions?
-
Rogers, North, & Housour, LLC is a large, regional CPA firm. There are 74 employees at their Glen Allen, SC office. The administrative assistant at this office approached Mr. Rogers, one of the...
-
Question no. 3 Quant Company issued $500,000 of 10%, 20-year bonds on January 1, 2010, at face value. Interest is payable semiannually on July 1 and January 1. Instructions: Prepare the journal...
-
Porter Company manufactures its one product by a process that requires two departments. The production starts in department A and is completed in department B. Materials are added at the beginning of...
-
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...
-
Construct a paragraph explaining the process of antigenic shift in the evolution of the H1N1 swine flu pandemic strain of influenza virus seen in2009.
-
460 V rms 3 phase full wave controlled rectifier feeds an inductive load. The supply voltage has a frequency of 50 Hz. If thyristors are considered ideal; a) Draw the voltage on the load when a = 25....
-
The following data is provided for Garcon Company and Pepper Company for the year ended December 31. Garcon Company Pepper Company Finished goods inventory, beginning $14,000 $17,950 Work in process...
-
On September 22, 2024, a flood destroyed the entire merchandise inventory on hand in a warehouse owned by the Rocklin Sporting Goods Company. The following information is available from the records...
-
A wound DC motor is connected in both a shunt and a series configuration. Assume generic resistance and inductance parameters Ra, Rf, La, Lf, let the field magnetization constant be kf and the...
-
Supermart Food Stores (SFS) has experienced net operating losses in its frozen food products line in the last few periods. Management believes that the store can improve its profitability if SFS...
-
Draw the shear and moment diagrams for the beam. 1.5 kN/m A B -2 m- 4 m
-
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.
-
() Y 0 0 0 0 0 0 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 D 0 1 1 0 1 1 1 1 0 1 0 1 7. For Exercise 2.6e implement the design in SV (there are multiple ways)...
-
Requirement. For each depreciation method prepare a depreciation schedule showing asset cost de connected dopeciation and book for the units of production method, round depreciation of unilla three...
-
Audit documentation of the evidence gathered by the auditor should meet which of the following criteria? (2 points) Workpapers are prepared in sufficient detail so that they can be given to the...
Study smarter with the SolutionInn App