Question: need help with the java program 3. Generating the paystub: Write, compile and run a Java program called PaystubPrinting.java that reads the following information as
need help with the java program
3. Generating the paystub: Write, compile and run a Java program called PaystubPrinting.java that reads the following information as user input through keyboard and prints a paystub statement: Employees name ( e. g., Robert), Number of hours worked in a week ( e. g., 10), Hourly pay rate ( e. g., 6.75), Federal tax withholding rate ( e. g., 20% for men or 15% for women), and State tax withholding rate ( e. g., 9%). Formatting Money Amounts with printf (Check the Week 4 section on eLearning to know more about printf) ? A good format specifier for outputting an amount of money stored as a double type is %.2f ? It says to include exactly two digits after the decimal point and to use the smallest field width that the value will fit into: double price = 4.56; System.out.printf("The price is $%.2f each.", price) produces the output: The price is $4.56 each.
Sample Run
Enter employee's name: Robert
Enter number of hours worked in a week: 40 Enter hourly pay rate: 12.5
Enter federal tax withholding rate: .20
Enter state tax withholding rate: .09 ----------------------------------------------- WEEKLY PAYSTUB Employee Name: Robert
Hours Worked: 40.00
Pay Rate: $12.50
Gross Pay: $500.00
Deductions:
Federal Withholding (20.0%): $100.00
State Withholding (9.0%): $45.00
Total Deduction: $145.00
Net Pay: $355.00 ----------------------------------------------- Second Run Enter employee's name: Liz Enter number of hours worked in a week: 40 Enter hourly pay rate: 22 Enter federal tax withholding rate: 0.15 Enter state tax withholding rate: 0.09 ----------------------------------------------- WEEKLY PAYSTUB Employee Name: Liz Hours Worked: 40.0 Pay Rate: $22.0 Gross Pay: $880.0 Deductions: Federal Withholding (20.0%): $132.00 State Withholding (9.0%): $79.20 Total Deduction: $211.20 Net Pay: $668.80 -----------------------------------------------
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
