Chapter 2 - What you need to know for a quiz on Monday!!
Formatted output: the printf statement
You will need to know the descriptors for float and double (e.g. %10.4f), integers and longs (e.g. %8d),
Strings (e.g. %20s). You should also know how to left justify numbers!!
Input: using the Scanner class
So what's on the quiz ? OK. Here's a good practice problem:
The current Social Security withholding is 6.2% and Medicare Hospital Insurance is 1.45%. Write a complete
java program that:
1) Prompts the users for an hourly rate (a double)
2) Prompts the user for hours worked ( a double)
3) Outputs
Gross Pay
Social Security Withholding
Medicare Withholding
Net Pay
All numeric output should have two digits past the decimal point.
Example Run:
Enter hourly rate: 10.0
<-- user
entered 10.0
Enter hours worked: 40.0
<-- user entered 40.0
Gross Pay : 400.00
<-- computer calculated gross pay and
output it
Social Security Withholding: 24.80
<-- computer calculated 400 * 0.62 and output it
Medicare Withholding : 5.80
<-- computer calculated 400 * 0.0145 and output it
Net Pay: 369.40
<-- computer calculated this
and output it