Question
In this exercise, youll use a decision structure and arithmetic expressions to calculate the federal income tax that is owed for a taxable income amount
In this exercise, youll use a decision structure and arithmetic expressions to calculate the federal income tax that is owed for a taxable income amount entered by the user. Then, youll design a method to contain the calculation code, and develop the calling statement to invoke the method.
You can test your step 1 results first (no private methods) and then move on to Step 2, which involves you moving the tax calculation code from the btnCalculate click event to a private method.
This is the 201x table for the federal income tax on individuals that you should use for calculating the tax:
Taxable income | Income tax | ||
Over | But not over |
| Of excess over |
$0 | $8,700 | $0 plus 10% | $0 |
$8,700 | $35,350 | $870 plus 15% | $8,700 |
$35,350 | $85,650 | $4867 plus 25% | $35,350 |
$85,650 | $178,650 | $17,442 plus 28% | $85,650 |
$178,650 | $388,350 | $43,482 plus 33% | $178,650 |
$388,350 |
| $112,683 plus 35% | $388,350 |
Start a new project named TaxCalculator.
- Add labels, text boxes, and buttons to the default form and set the properties of the form and its controls so they appear as shown above. When the user presses the Enter key, the Click event of the Calculate button should fire. When the user presses the Esc key, the Click event of the Exit button should fire.
- Create an event handler for the Click event of the Exit button that closes the form.
- Step 1 calculate the tax owed in bntCalculate_Click event handler. This code should provide for decimal entries, and you can assume that the user will enter valid decimal values. However, do better than the screenshot above and actually display the results as currency. Note: The amount of Federal Income Tax owed is usually a whole dollar amount, and the government doesnt round up rather, they convert it to an integer, effectively losing the cents. That is the reason for the amount listed in the screenshot.
Step 2 - Code the declaration for a private method named CalculateTax that receives the income amount and returns the tax amount. Create a statement in the btnCalculate_Click event handler that declares the tax variable which, in turn, gets its value by calling this CalculateTax method.
- Create an event handler that clears the Income Tax Owed text box if the user changes the value in the Taxable Income text box.4
- Test the application to be sure it works correctly.
*Please do in C#, Windows Forms Application, and Visual Studios*
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started