Question: 6 . 2 3 Java example: Salary calculation with methods zyDE 6 . 2 3 . 1 : Calculate salary: Using methods. Separating calculations into
Java example: Salary calculation with methods
zyDE : 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.
Run the program below with annual salaries of and
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?
Note: The calculation is inaccurate to how taxes are formally assessed and is a simplification for educational purposes only.
Load default template...
FIXME: Change the input to come from a method
annualSalary scnrnextInt;
while annualSalary
taxRate getCorrespondingTableValueannualSalary salaryBase, taxBase;
taxToPayintannualSalary taxRate; Truncate tax to an integer amount
System.out.printlnAnnual 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 to exit: ;
annualSalary scnrnextInt;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
