Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following Java code outputs various amounts for a worker based on skill level, hours worked, and insurance: import java.util.Scanner; public class Pay { public

The following Java code outputs various amounts for a worker based on skill level, hours worked, and insurance:

import java.util.Scanner; public class Pay { public static void main(String[] args) { int SkillOneRate = 17; int SkillTwoRate = 20; int SkillThreeRate = 22; double MedicalInsurance = 32.50; double DentalInsurance = 20.00; double DisabilityInsurance = 10.00; int skill,hours; int choice; char y; char n; int payRate =0; double regularPay = 0; double overtimePay = 0; double grossPay=0; double deductions=0; double netPay = 0; Scanner input = new Scanner(System.in); System.out.println("Enter skill level: 1. 2. 3."); skill = input.nextInt(); System.out.println("Ener hours worked: "); hours = input.nextInt(); if(skill == 1) { payRate = SkillOneRate; } else if(skill == 2) { payRate = SkillTwoRate; } else if(skill == 3) { payRate = SkillThreeRate; } if(hours>40) { regularPay = 40*payRate; overtimePay = (hours-40)*payRate*1.5; } else { regularPay = hours*payRate; grossPay = (regularPay + overtimePay); } if(skill==2 || skill==3) { System.out.println("Enter Insurance: 1.Medical Insurance 2.Dental Insurance 3.Disability Insurance"); int insuranceType = input.nextInt(); if(insuranceType == 1) { deductions = MedicalInsurance; } else if(insuranceType == 2) { deductions = DentalInsurance; } else if(insuranceType == 3) { deductions = DisabilityInsurance; } if(skill==3) { System.out.println("Retirement Plan with 3% gross pay: Enter 1 for yes Enter 2 for no"); Scanner input2 = new Scanner(System.in); choice = input2.nextInt(); if(choice == 1) { double retirementCost = grossPay*.03; deductions = deductions+retirementCost; grossPay = grossPay-deductions; } } } System.out.println("Employee Data: Hours: " +hours+" Pay Rate: "+payRate+" Regular Pay: "+regularPay+" Overtime Pay: "+overtimePay+" Total = Regular + Overtime: "+(regularPay+overtimePay)+" Deductions: "+deductions+" Net Pay: "+netPay); } }

Please make the following three modifications to the code:

1. 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.

2.Use a do...while() loop to ask the user for their skill level. Keep looping until a valid skill level is provided.

3. Use a JOptionPane to show the workers gross pay.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions