Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I wrote the code for this problem and then i noticed my teacher made some min

ID: 666579 • Letter: S

Question

So I wrote the code for this problem and then i noticed my teacher made some minor adjustments that he would like to add on to the orginal problem. Can you please help with the modificaitons.

//6. Barnhill Fastener Company runs a small factory. The company employs workers who
// are paid one of three hourly rates depending on skill level:
// Each factory worker might work any number of hours per week; any hours over 40 are
// paid at one and one-half times the usual rate.
// In addition, workers in skill levels 2 and 3 can elect the following insurance
// options:
// Skill Level   Hourly Pay Rate ($)
// 1   17.00
// 2   20.00
// 3   22.00
//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.

// Write an 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. Save the file as Pay.java.

------------------------------------------------------------------------------------------------------------------------------------------

new requirements

• Use three JOptionPane Confirm Dialog Boxes (using the JOptionPane.YES_NO_OPTION) to ask the worker if they want medical insurance, dental insurance, and long-term disability insurance, as the worker can enroll in more than one insurance option. • Use a do...while() loop to ask the user for their skill level. Keep looping until a valid skill level is provided. • Use a JOptionPane to show the worker’s gross pay.

________________________________________________________________________________________

import java.util.Scanner;
public class Pay
{
public static void main(String[]args)
{
//skill level demands
int skillLevel;
double skillPay = 0.00;
String message = "";
//skill level code entries
final int SKILL_LEVEL1 = 1;
final int SKILL_LEVEL2 = 2;
final int SKILL_LEVEL3 = 3;
//skill level hrly rate
final double SKILL_PAY1 = 17.00;
final double SKILL_PAY2 = 20.00;
final double SKILL_PAY3 = 22.00;
//Insurance
int insType;
double insCost = 0.00;
int end = 0;
  
//Insurance entries
final int MEDICAL_INS = 1;
final int DENTAL_INS = 2;
final int LONG_INS = 3;
final int OPT_OUT = 4;
//Insurance cost
final double MEDICAL_COST = 32.50;
final double DENTAL_COST = 20.00;
final double LONG_COST = 10.00;
final double OPT_COST = 0.00;
//sum of total cost for insurance per week
double INS_DEDUCTION = 0.00;
//retirement plan
int retPlan=0;
double retCost = 0;

final int RET_PLAN = 1;
final int NO_RET_PLAN = 2;

//hours worked in a week
double hoursWorked;
double regularPay;
double overtimePay;
final int FULL_WEEK = 40;
final double OT_RATE =1.5;
//Final income after deductions
  
Scanner input = new Scanner(System.in);
//Skill level input
System.out.println("Barnhill Fastener Company has assigned you a skill level");
System.out.println("Please input the skill level: ");
skillLevel = input.nextInt();

//switch statement for skill level   
switch(skillLevel)
{
case SKILL_LEVEL1:
skillPay = SKILL_PAY1;
message = "Skill Level 1";
break;
case SKILL_LEVEL2:
skillPay = SKILL_PAY2;
message = "Skill Level 2";
break;
case SKILL_LEVEL3:
skillPay = SKILL_PAY3;
message = "Skill Level 3";
break;
default:
skillPay = 0.00;
message = "Invalid skill level selection";
System.out.println("Please choose a skill level from 1-3");
}
System.out.println("You have choosen: " + message);
System.out.println("Your hourly pay is $" + skillPay);   
// if...else statement for insurance   

if(skillLevel == 2 || skillLevel == 3)
{
System.out.println("We offer Skill level 2 & 3 different types of insurance");
System.out.println("Here are our options of insurance");
System.out.println("_______________________________________________________________________");
System.out.println(" Weekly Cost ");
System.out.println(" (1) - Medical insurance $32.50");
System.out.println(" (2) - Dental insurance $20.00");
System.out.println(" (3) - Long-term disability insurance $10.00");
System.out.println(" (4) - OPT OUT of insurance $ 0.00");
System.out.println("_______________________________________________________________________");
System.out.println("Please choose an insurance type:");
INS_DEDUCTION+=insCost;
  
insType = input.nextInt();
if(insType==1)
{
insCost=MEDICAL_COST;
}
else if(insType==2)
{
insCost=DENTAL_COST;
}
else if(insType==3)
{
insCost=LONG_COST;
}
else
{
insCost=OPT_COST;
}
System.out.println("You made a good decision with " + insType);
System.out.printf("Insurance deductions are: $ %.2f " ,insCost);
  

}

//if...else statement for RETIREMENT plan for 3% of gross income
if(skillLevel == 3)
{
  
System.out.println("Level 3 canidates have the option of retirement");
System.out.println("Our retirement policy just sets aside 3% of your weekly gross income");
System.out.println("If you would like to add retirement plane [enter] - 1 otherwise [enter] - 2");
retPlan = input.nextInt();
  

}
if(skillLevel==1 || skillLevel==2 || skillLevel==3)
System.out.print("How many hours did you work this week? ");
hoursWorked = input.nextDouble();


if(hoursWorked > FULL_WEEK)
{
regularPay = FULL_WEEK * skillPay;
overtimePay = (hoursWorked - FULL_WEEK) * OT_RATE * skillPay;
}
else
{
regularPay = hoursWorked * skillPay;
overtimePay = 0.0;
}
if(retPlan == 1)
{

retCost = (regularPay+overtimePay)*.03;
}
else {
retCost=0;
}
double finalIncome = ((regularPay+overtimePay)-(retCost+insCost));   

System.out.println("Regular pay is " + regularPay + " Overtime pay is " + overtimePay);   
System.out.printf("Your paycheck will amount to $" + finalIncome + " after deductions");
}
}

Explanation / Answer

import java.util.Scanner;
public class Pay
{
public static void main(String[]args)
{
//skill level demands
int skillLevel;
double skillPay = 0.00;
String message = "";
//skill level code entries
final int SKILL_LEVEL1 = 1;
final int SKILL_LEVEL2 = 2;
final int SKILL_LEVEL3 = 3;
//skill level hrly rate
final double SKILL_PAY1 = 17.00;
final double SKILL_PAY2 = 20.00;
final double SKILL_PAY3 = 22.00;
//Insurance
int insType;
double insCost = 0.00;
int end = 0;
  
//Insurance entries
final int MEDICAL_INS = 1;
final int DENTAL_INS = 2;
final int LONG_INS = 3;
final int OPT_OUT = 4;
//Insurance cost
final double MEDICAL_COST = 32.50;
final double DENTAL_COST = 20.00;
final double LONG_COST = 10.00;
final double OPT_COST = 0.00;
//sum of total cost for insurance per week
double INS_DEDUCTION = 0.00;
//retirement plan
int retPlan=0;
double retCost = 0;

final int RET_PLAN = 1;
final int NO_RET_PLAN = 2;

//hours worked in a week
double hoursWorked;
double regularPay;
double overtimePay;
final int FULL_WEEK = 40;
final double OT_RATE =1.5;
//Final income after deductions
  
Scanner input = new Scanner(System.in);
//Skill level input
System.out.println("Barnhill Fastener Company has assigned you a skill level");
System.out.println("Please input the skill level: ");
skillLevel = input.nextInt();

//switch statement for skill level   
switch(skillLevel)
{
case SKILL_LEVEL1:
skillPay = SKILL_PAY1;
message = "Skill Level 1";
break;
case SKILL_LEVEL2:
skillPay = SKILL_PAY2;
message = "Skill Level 2";
break;
case SKILL_LEVEL3:
skillPay = SKILL_PAY3;
message = "Skill Level 3";
break;
default:
skillPay = 0.00;
message = "Invalid skill level selection";
System.out.println("Please choose a skill level from 1-3");
}
System.out.println("You have choosen: " + message);
System.out.println("Your hourly pay is $" + skillPay);   
// if...else statement for insurance   

if(skillLevel == 2 || skillLevel == 3)
{
System.out.println("We offer Skill level 2 & 3 different types of insurance");
System.out.println("Here are our options of insurance");
System.out.println("_______________________________________________________________________");
System.out.println(" Weekly Cost ");
System.out.println(" (1) - Medical insurance $32.50");
System.out.println(" (2) - Dental insurance $20.00");
System.out.println(" (3) - Long-term disability insurance $10.00");
System.out.println(" (4) - OPT OUT of insurance $ 0.00");
System.out.println("_______________________________________________________________________");
System.out.println("Please choose an insurance type:");
INS_DEDUCTION+=insCost;
  
insType = input.nextInt();
if(insType==1)
{
insCost=MEDICAL_COST;
}
else if(insType==2)
{
insCost=DENTAL_COST;
}
else if(insType==3)
{
insCost=LONG_COST;
}
else
{
insCost=OPT_COST;
}
System.out.println("You made a good decision with " + insType);
System.out.printf("Insurance deductions are: $ %.2f " ,insCost);
  
}
//if...else statement for RETIREMENT plan for 3% of gross income
if(skillLevel == 3)
{
  
System.out.println("Level 3 canidates have the option of retirement");
System.out.println("Our retirement policy just sets aside 3% of your weekly gross income");
System.out.println("If you would like to add retirement plane [enter] - 1 otherwise [enter] - 2");
retPlan = input.nextInt();
  

}
if(skillLevel==1 || skillLevel==2 || skillLevel==3)
System.out.print("How many hours did you work this week? ");
hoursWorked = input.nextDouble();


if(hoursWorked > FULL_WEEK)
{
regularPay = FULL_WEEK * skillPay;
overtimePay = (hoursWorked - FULL_WEEK) * OT_RATE * skillPay;
}
else
{
regularPay = hoursWorked * skillPay;
overtimePay = 0.0;
}
if(retPlan == 1)
{

retCost = (regularPay+overtimePay)*.03;
}
else {
retCost=0;
}
double finalIncome = ((regularPay+overtimePay)-(retCost+insCost));   
System.out.println("Regular pay is " + regularPay + " Overtime pay is " + overtimePay);   
System.out.printf("Your paycheck will amount to $" + finalIncome + " after deductions");
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote