Skill Level/Hourly Pay Rate ($) 1/17 2/20 3/22 Option/Explanation/Weekly Cost to
ID: 3659695 • Letter: S
Question
Skill Level/Hourly Pay Rate ($)
1/17
2/20
3/22
Option/Explanation/Weekly Cost to Employee ($)
1/Medical Insurance/32.50
2/Dental Insurance/20.00
3/Long-Term Disability Insurance/10.00
Also, workers in skill level 3 can elect to participate in the retirement plan at 3% of their gross pay.
I need to write a interactive Java payroll application that calculates the net pay for a factory worker. The program prompts the user for skill level and hours worked, as well as appropriate insurance and retirement options for the employee's skill level category. The application displays: (1) the hours worked, (2) the hourly pay rate, (3) the regular pay for 40 hours, (4) the overtime pay, (5) the total of regular and overtime pay, and (6) the total itemized deductions. If the deductions exceed the gross pay, display an error message; otherwise, calculate and display (7) the net pay after all the deductions have been subtracted from the gross.
I also need to:
Explanation / Answer
please rate - thanks
didn't understand everything you were doing, so this is the best I could do
import java.util.*;
import javax.swing.*;
import javax.swing.JOptionPane;
public class Payroll
{
public static void main(String[] args)
{
int choice;
choice = 0;
double retirement=0;
double insurance;
double totalPay;
insurance = 0;
double rate;
rate = 0;
int option;
double hoursWorked;
double regularPay;
double overtimePay;
double netPay;
int skillLevel;
final int FULL_WEEK = 40;
final double OT_RATE = 1.5;
Scanner keyboard = new Scanner(System.in);
do
{System.out.print("What is your skill level? Enter 1, 2, or 3: ");
skillLevel = keyboard.nextInt();
if(skillLevel == 1)
rate = 17.00;
else if(skillLevel == 2)
rate = 20.00;
else if(skillLevel == 3)
rate = 22.00;
else
System.out.println("Invalid skill level.");
}while(skillLevel<1||skillLevel>3);
System.out.print("How many hours did you work this week?");
hoursWorked = keyboard.nextDouble();
if(hoursWorked > FULL_WEEK)
{
regularPay = FULL_WEEK * rate;
overtimePay = (hoursWorked - FULL_WEEK) * OT_RATE * rate;
}
else
{
regularPay = hoursWorked * rate;
overtimePay = 0.0;
}
int n = JOptionPane.showConfirmDialog(null,"You want medical insurance?",
null, JOptionPane.YES_NO_OPTION);
//use value of n for other loops as activator
if(n==JOptionPane.YES_OPTION){insurance+=32.5;
}
int m = JOptionPane.showConfirmDialog(null,"You want dental insurance?",
null, JOptionPane.YES_NO_OPTION);
if(m==JOptionPane.YES_OPTION){insurance+=20;
}
int b = JOptionPane.showConfirmDialog(null,"You want long term disability insurance?",
null, JOptionPane.YES_NO_OPTION);
if(b==JOptionPane.YES_OPTION){insurance+=10;
}
if(skillLevel == 3)
{System.out.println("Would you like to participate in the retirement plan? Enter 1 for yes or 0 for no: ");
choice = keyboard.nextInt();
if(choice == 1)
retirement = 0.03;
else
retirement = 0;
}
totalPay = regularPay + overtimePay;
retirement*=retirement*totalPay;
netPay = totalPay - insurance-retirement;
System.out.println("Regular pay is " +
regularPay + " Overtime pay is " + overtimePay + " Hours worked: " + hoursWorked +
" Your hourly rate is: " + rate + " Total gross pay is: " + (regularPay + overtimePay) +
" Your total deductions are: Insurance " + insurance + " Retirement"+retirement);
if(retirement+insurance>totalPay)
System.out.println("Your deductions are more than your pay");
else
System.out.println("Your net pay is: " + netPay);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.