Due date: Wednesday, February 19, 2020.
Objective: To use conditionals and type casting in Java.
In this project, we will calculate a tax amount based on the annual income amount and some rules. We will display the result in a two decimal format.
Create a Java project in Eclipse and call it hw5. Create a class in this project called Tax and containing the main method. Write your name, course, semester, and homework number at the top as a comment.
a. Input. Declare two float variables for the income value and for the tax value. Repeat the usual steps to declare a Scanner in your program. Input the income from the user with an appropriate message and using the method nextFloat().
b. Tax Calculation. Next, compute the amount of the tax according to the following (simplified!) rules:
You will need some conditionals to separate the different cases.
c. Output. We would like to output the amount of the tax rounded up to the cent, meaning using only two decimals. For this, first multiply the number by 100. This will bring the first two decimals over to the left of the period. Then type cast it to an integer to truncate all the remaining decimals. Then divide the result by 100.0 to bring it back to the original amount (minus some decimals) and to convert it back to a float.
Finally, you can now output the result. In the output statement, put a $ sign in front of the amount.
Upload the lab and homework .java files: SecretNumber.java and Tax.java, to Canvas in Assignments - Homework 5.