Execute the same computations repeatedly

Assignment Help Business Management
Reference no: EM131740173

A program may execute the same computations repeatedly.

The program below repeatedly asks the user to enter an annual salary, stopping when the user enters 0 or less. For each annual salary, the program determines the tax rate and computes the tax to pay.

  1. Run the program below with annual salaries of 40000, 90000, and then 0.
  2. Modify the program to use a while loop inside the given while loop. The new inner loop should repeatedly ask the user to enter a salary deduction, stopping when the user enters a 0 or less. The deductions are summed and then subtracted from the annual income, giving an adjusted gross income. The tax rate is then calculated from the adjusted gross income.
  3. Run the program with the following input: 40000, 7000, 2000, 0, and 0. Note that the 7000 and 2000 are deductions

import java.util.Scanner;

public class IncomeTax {

  public static void main (String [] args) {

     Scanner scnr = new Scanner(System.in);

     final String SALARY_PROMPT = "nEnter annual salary (0 to exit): ";

     int   annualSalary   = 0;

     int   deduction      = 0;

     int   totalDeductions = 0;

     double taxRate        = 0.0;

     int   taxToPay       = 0;

     System.out.println(SALARY_PROMPT);

     annualSalary = scnr.nextInt();

     while (annualSalary > 0) {

        // FIXME: Add a while loop to gather deductions. Use the variables

        // deduction and totalDeduction for deduction handling.

        // End the inner while loop when a deduction <= 0 is entered.

        // Determine the tax rate from the annual salary

        if (annualSalary <= 20000) {

           taxRate = 0.10;       // 0.10 is 10% written as a decimal

        }

        else if (annualSalary <= 50000) {

           taxRate = 0.20;

        }

        else if (annualSalary <= 100000) {

           taxRate = 0.30;

        }

        else {

           taxRate = 0.40;

        }

        taxToPay = (int)(annualSalary * taxRate);  // Truncate tax to an integer amount

        System.out.println("Annual salary: " + annualSalary);

        System.out.println("Tax rate: " + taxRate);

        System.out.println("Tax to pay: " + taxToPay);

        // Get the next annual salary

        System.out.println(SALARY_PROMPT);

        annualSalary = scnr.nextInt();

     }

     return;

  }

Reference no: EM131740173

Questions Cloud

Screen capture of successfully running the code : Find a simple mathematical formula and implement it in C code. Be sure to test your Code in the online IDE.
Identify the legal issues presented by these classifications : Summarize the factual background on how the students are classified; Identify the legal issues presented by these classifications;
Validate an idea with your own experience : What resources did you find? Post the links and describe the sites. Why do you find these resources beneficial for small business entrepreneurs?
Identify the bone feature labeled c : Which of the following bone features is correctly matched with the bone on which it is found? Identify the bone feature labeled c.
Execute the same computations repeatedly : The program below repeatedly asks the user to enter an annual salary, stopping when the user enters 0 or less. For each annual salary
Solving problem of an equation-counting argument : Use an equation-counting argument to justify the fact that contact of order six or greater between lines and surfaces does not occur for generic surfaces.
Research the potential costs of launching your venture : Research the potential costs of launching your venture, and use this research to develop a 1-page start-up and marketing budget for your venture.
Define integral curves of the field of principal directions : We saw that the asymptotic curve and its spherical image have perpendicular tangents. Lines of curvature are the integral curves of the field of principal.
Review the school board policy and student handbook : write a 500-750-word essay summarizing the due process requirements prior to a short-term and a long-term suspension of a student at that site.

Reviews

Write a Review

Business Management Questions & Answers

  Determine the amount of dollars that narto co

Determine the amount of dollars that Narto Co. will receive at the end of one year if it implements a money market hedge.

  Inadequate the companies'' hr strategies

Why do you think having an HR strategy is important for a company?

  Human factors in maintenance

For research paper I, you must choose an airline or organization that has been affected by Human Factors in maintenance. Remember, not all human factors are related to maintenance faults. Maintenance faults can be contributed from maintenance crew..

  Explain the risks that an international fast food restaurant

Explain the risks that an international fast food restaurant, such as Subway, would have by operating abroad rather than just domestically.

  Challenge for most organization

How does Workforce diversity could be a challenge for most organization and to manage it in a perfect manner causing a significant competitive benefit?

  Assistant hr manager at crothwall and associates

Assume that you are an assistant HR manager at Crothwall and Associates. You need to inform Nancy that she has received a C grade on her performance.

  Discuss how a chiropractic clinic will serve patients

Discuss how a chiropractic clinic will serve patients with a mental illness and Discuss at least two different categories of mental illness from this list

  How would you value the goodwill

The reason for that is to create goodwill and how would you value the goodwill that is obtained in this way?

  Scale-efficiency and customization simultaneously

Discuss the manufacturing and other techniques that allows today's firms to address needs of scale/efficiency and customization simultaneously.

  Sociological perspectives on family issuesdiscuss family

sociological perspectives on family issuesdiscuss family and family issues within the major sociological perspectives.

  What articulated the media budget

What would you do if you were articulated the media budget will be lost as well as the agency that hired you would lose business if the ROI is not greater than $1.

  To what extent can our legal system ensure order in society

To what extent can our legal system ensure order and stability in society and particularly, in the business world? Give a recent example from your research concerning any alleged failure of the legal system.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd