Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Im stuck
Expert Solution
arrow_forward
Step 1
Note:
- Comments mentioned in the code for understandability.
- In the implementation:
- If skill level =1 then hourlypay rate considered as 17.
- If skill level =2 then hourlypay rate considered as 20.
- If skill level =3 then hourlypay rate considered as 22.
Code:
import javax.swing.JOptionPane;
public class Pay
{
public static void main(String argds[])
{
//variable declaration
int REGULAR_HOURS =40;
int skillLevel;
int hoursWorked;
int medicalOption;
int dentalOption;
int disabilityOption;
double medicalCost=0.0;
double dentalCost=0.0;
double disabilityCost=0.0;
int retirementPlan;
double hourlyPayRate;
double regularPay;
int overtimeHoursWorked;
double overtimePay;
double totalPay;
double deductions;
double insuranceCost;
double retirementCost;
double netPay;
//Getting skill Level from user
do{
skillLevel =Integer.parseInt(JOptionPane.showInputDialog("Please Enter sill level: 1,2 or 3 "));
} while(skillLevel<1 || skillLevel>3);
//Getting hours worked from user
hoursWorked =Integer.parseInt(JOptionPane.showInputDialog("Please Enter Hours worked: "));
//getting Medical insurance option from user
do{
medicalOption =Integer.parseInt(JOptionPane.showInputDialog("Do you want the medical insurance?\nEnter 1 for Yes and 2 for No. "));
}while(medicalOption<1 || medicalOption>2);
// Getting dental insurance option from user
do{
dentalOption =Integer.parseInt(JOptionPane.showInputDialog("Do you want the dental insurance?\nEnter 1 for Yes and 2 for No. "));
}while(dentalOption<1 || dentalOption>2);
// Getting diability insurance option from user
do{
disabilityOption =Integer.parseInt(JOptionPane.showInputDialog("Do you want the long term disability insurance?\nEnter 1 for Yes and 2 for No. "));
}while(disabilityOption<1 || disabilityOption>2);
//Calculating hourly pay rate based on skill level
switch(skillLevel)
{
case 1:
hourlyPayRate = 17.00;
break;
case 2:
hourlyPayRate = 20.00;
break;
case 3:
hourlyPayRate = 22.00;
break;
default:
hourlyPayRate = 0.0;
}
//Calculating regular pay and overtime pay vased on hours worked
if(hoursWorked > 40)
{
regularPay = REGULAR_HOURS * hourlyPayRate;
overtimeHoursWorked = hoursWorked - REGULAR_HOURS;
overtimePay=overtimeHoursWorked*(hourlyPayRate*1.5);
}
else
{
regularPay = hoursWorked * hourlyPayRate;
overtimePay= 0.0;
}
//Claculate totalpay
totalPay = regularPay +overtimePay;
//Calculating Insurance cost based on medical,dental and disability insurance options.
insuranceCost= 0.0;
if(medicalOption == 1)
{
insuranceCost += 32.50;
medicalCost =32.50;
}
if(dentalOption == 1)
{
insuranceCost += 20.00;
dentalCost =20.00;
}
if(disabilityOption == 1)
{
insuranceCost += 10.00;
disabilityCost =10.00;
}
//calculating retiremnet cost based on skill level.
retirementCost=0.0;
if(skillLevel == 3)
{
retirementCost = (totalPay * 3)/100;
}
//Calculating deductions
deductions = insuranceCost + retirementCost;
//if deductions is greater than total pay then error message is displayed.
if(deductions > totalPay)
{
JOptionPane.showMessageDialog(null,"Error: the deductions exceed the gross pay, so deductions set to 0.");
deductions=0.0;
}
//calculating total pay
netPay = totalPay - deductions;
//Desgining a string to display output
String s1= "******* Gross Pay *******"
+"\n Hours Worked: "+hoursWorked
+"\n Hourly Pay rate: "+hourlyPayRate
+"\n Regular Pay: "+regularPay
+"\n Overtime Pay: "+overtimePay
+"\n Total Pay: "+totalPay
+ "\n\n******* Deductions *******"
+"\n Medical: "+medicalCost
+"\n Dental: "+dentalCost
+"\n Disability: "+disabilityCost
+"\n Retirement: "+retirementCost
+"\n Total deductions: "+deductions
+"\n\nNet Pay: "+netPay;
// Display string
JOptionPane.showMessageDialog(null,s1);
}
}
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 10 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Explain the correct answer and also why other options are wrong. Thank you!!!arrow_forwardIs the following code for a wall mural a valid UPC number? If not, what should the check digit be in order to make this a valid UPC code> 0 88085 10811 4arrow_forwardShould not it be 0x0DD35. you answer is 0x 0D35arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education