|
|
Java Student Project |
||
|
|||
Payroll |
|||
|
|
|
||
| Ability Level: | Intermediate | ||
|
|
|
||
| Estimated Time: | 50 minutes | ||
|
|
|
||
| Objectives: |
|
||
|
|
|
||
| Materials & Resources: |
|
||
|
|
|
||
| Overview: | Write a program that stores an
hourly pay rate and hours worked. Compute gross pay (hours times
rate), withholding tax, and net pay (gross pay minus withholding
tax).
Use the System.in.read( ) and ask the user for the pay rate and
hours. Withholding tax is computed as a percentage of gross pay
based on the following: Gross Pay Withholding Percentage Up to and including 300.00 10 300.01 and including 400.00 12 400.01 and including 500.00 15 500.01 and up 20 |
||
|
|
|
||
| Instructions: | See the notes in overview above. | ||
|
|
|
||
| Hints: | Some important
points to keep in mind in doing this project:
You can place and indent the if following an else, but a program with many nested if…else combinations soon grows very long and “deep,” and with indentations, later statements in the nest would move farther and farther to the right on the page. For easier-to-read code, Java programmers constantly place each else and it’s subsequent if on the same line. Remember that you reference character values using single quotation marks. Indentations in the if...else are not required, but is standard usage. You vertically align the keyword if the keyword else, and then indent the action statements that depend on the evaluation. You can code an if without an else, but it is illegal to code an else without an if. When you create a block, you do not have to place multiple statements within it. It is perfectly legal to block a single statement. An if statement ends with a semicolon. Making a decision involves choosing between two alternative courses of action based on some value within a program. You can use the if statement to make a decision based on a boolean expression that evaluates as true or false. If the boolean expression enclosed in parentheses within an if statement is true, then the subsequent statement or block will execute.
Within an if or an else statement, you can code as many dependent statements as
you need, including other if and else statements. Nested if statements are
particularly useful when two conditions must be met before some action occurs. |
||
|
|
|
||
| Extra: | |||