Assignment: Event-Driven programming
Learning Objectives:
This assignment is designed to practice:
1. Implement JavaScript code which will handle user events.
2. Display feedback to the user in case of data entry errors.
3. Use of the conditional if and if/else statements.
4. Use of arithmetic and logic operators.
5. Use of comments.
Tax Return processing program
Requirements:
The company that needed the flowchart and pseudocode for calculating the Tax Owed amount for tax returns is now giving you the responsibility of creating a program for that purpose.
The requirements for performing the calculation remain the same as those indicated for the flowchart:
For citizens younger than 21, the tax applied is one of the following:
8% for income up to $20,000.
12% for income greater than $20,000 up to $50,000.
20% for income greater than $50,000.
For citizens 21 years old or older, the tax applied is one of the following:
10% for income up to $20,000.
15% for income greater than $20,000 up to $35,000.
25% for income greater than $35,000 up to $70,000.
30% for income greater than $70,000.
- The formula to calculate the Tax Owed amount is: tax rate percentage x income
The company has also provided a video - attached to these instructions on Sakai - that displays the way the program should work as well as the screen format when the program is run. (Note: on the video the program is run three times with different data entries).
Additional Requirements:
- You will enter a comment on the head section with your name on it.
- You will use radio buttons to acquire the age range of the user.
- You will use a text box to get the user's income data.
- You will use a Process button to process the Tax Owed amount.
- The button mentioned above should also:
* Produce an error message (via an alert window) if the user forgets to select a radio button.
* Produce an error message (via an alert window) if the user forgets to enter income data or enters data that cannot be processed such as text data.
- You will use text box to display the tax owed amount.
- You will use a Clear button to reset the main variables as well as the radio buttons and text boxes in order to be able to process the next user's information.
- The variable names should be descriptive. For example, if a program is calculating the tip given at a restaurant, an appropriate variable name may be tipAmount.
- The format of the screen should be similar to that provided on the video example.
Additional Information:
- Since the content of a text box - which is what the prompt() function generates - is going to be used in mathematical operations, use the function parseInt() to ensure that the numeric input is treated as numeric data.
Syntax example:
numericVariable = parseInt(numericVariable)
- Resetting dark circle of a radio button: use the checked property.
- Evaluating if there is no numeric value on a text box: use the isNaN function.
References:
- Recitation sessions
- Lectures
- Fluency textbook Chapters 17, 18
- w3schools website.