subject

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.
Run the program below with annual salaries of 40000, 60000, and 0.
Change the program to use a method to input the annual salary.
Run the program again with the same annual salaries as above. Are results the same?
This is the code including what I am working on added. I will not run. I need to remove some areas to designate the scanner as the source of input but I am unsure of which area.
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 (int search, int [] baseTable, double [] valueTable) {
int baseTableLength = baseTable. length;
double value = 0.0;
int i = 0;
boolean keepLooking = true;
i = 0;
while ((i < baseTableLength) && keepLooking) {
if (search <= baseTable[i]) {
value = valueTable[i];
keepLooking = false;
}
else {
++i;
}
}
return value;
}
public static void readInput(int salaryOne, int salaryTwo, int salaryThree);
annualSalary = 0;
Scanner scnr = new Scanner(System. in);
scnr nextInt();
new annualSalary;
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("\nEnter annual salary (0 to exit): ");
annualSalary = scnr. nextInt();
while (annualSalary > 0) {
taxRate = (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("\nEnter annual salary (0 to exit): ");
annualSalary = scnr. nextInt();
}
return;
}
}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 02:00, deeknuk
What is the main benefit of minimizing the ribbon in word? more options will be accessible through customized keystrokes. more of the document will be viewable without needing to scroll. fewer controls will be accessible to the user by using the mouse. fewer editing options will be available without entering a password.
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, emilyplays474
What key should you press and hold to select and open multiple files at one time? enter alt control esc
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, vetterk1400
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, rscvsdfsrysas3712
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
You know the right answer?
Separating calculations into methods simplifies modifying and expanding programs. The following pro...

Questions in other subjects:

Konu
Mathematics, 05.03.2021 16:40
Konu
Mathematics, 05.03.2021 16:40
Konu
Computers and Technology, 05.03.2021 16:40
Konu
English, 05.03.2021 16:40