Question: I need help with this java Assignment import java.util.Scanner; public class IncomeTax { // Method to get a value from one table based on a

I need help with this java Assignment

I need help with this java Assignment import java.util.Scanner; public class IncomeTax

import java.util.Scanner;

public class IncomeTax { // Method to get a value from one table based on a range in the other table public static double getCorrespondingTableValue(int search, int[] baseTable, double[] valueTable) { int baseTableLength = baseTable.length; double value = 0.0; int i = 0; boolean keepLooking = true;

i = 0; while ((i

return value; }

public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int annualSalary = 0; double taxRate = 0.0; int taxToPay = 0; int i = 0;

int[] salaryBase = { 20000, 50000, 100000, 999999999 }; double[] taxBase = { .10, .20, .30, .40 };

// FIXME: Change the input to come from a method System.out.println(" Enter annual salary (0 to exit): "); annualSalary = scnr.nextInt();

while (annualSalary > 0) { taxRate = getCorrespondingTableValue(annualSalary, salaryBase, taxBase);

taxToPay = (int) (annualSalary * taxRate); // Truncate tax to an integer amount System.out .println("Annual salary: " + annualSalary + "\tTax rate: " + taxRate + "\tTax to pay: " + taxToPay);

// Get the next annual salary // FIXME: Change the input to come from a method System.out.println(" Enter annual salary (0 to exit): "); annualSalary = scnr.nextInt(); }

return; } }

4. Calculate salary: Using methods. Separating calculations into methods simplifies modifying and expanding programs The following program calculates the tax rate and tax to pay, using methods. One method returns a tax rate based on an annual salary. 1. Run the program below with annual salaries of 40000, 60000, and 0 2. Change the program to use a method to input the annual salary. nual salaries as abov

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!