I need someone to help me write this exercise in java code plz. Exercise 2 (10 m
ID: 3757379 • Letter: I
Question
I need someone to help me write this exercise in java code plz.
Exercise 2 (10 marks) (Ex2.java write a java program that shall solve the following problem: A Small supermarket employs woxsesuba are paid every end of week. According to the one of the three hourly rates depending on their positions. Position Admin A1 Worker P1 Worker P2 Hours rate (dirham) 60 40 30 Each worker might work any number of hours per week; any hour over 40 are paid at one and halfrate. In addition workers in position Al and P1 can choose to participate in the following inssuance options Option Explanation I1Medical Inssurance I2 Dental Inssurance 13 Disability Iassurance Weekly Cost to Employee (dirham) 80 50 30 Also, the worker Admin in position A1 can choose to participate in the retirement plan at 3.0% of their gross pay. The following table summarise who is authorized to participate in insurance and retirement plans Position | 11 | 12 | 13 | Retirement (3%) Admin A Y Y Y Worker P1 Y Y Y Worker P2 | N | N N Write an interactive Java payroll application that calculates the net pay for a worker. The program propmpts the user for: ski level and hours worked, as well as appropriate insurance and retirement options for the wrokec's position The application displays: 1) hours worked, 2) hourly rate, 3) regular pay for 40 hours. 4) overtime pay, 5) total pay, 6) total deductions, 7) the net pay (total pay-total deductions).Explanation / Answer
import java.io.*;
import java.util.Scanner;
class GFG {
public static void main (String[] args) {
int skill,hours,hrate;
double pay,regpay,overpay,totpay;
double ded;
char ch;
Scanner sc = new Scanner(System.in);
System.out.println("Enter skill level: Admin A1(1) Worker P1(2) Worker P2(3)");
skill=sc.nextInt();
System.out.println("Enter hours worked");
hours=sc.nextInt();
if(skill==1)
hrate=60;
else if(skill==2)
hrate=40;
else
hrate=30;
regpay=hours*hrate;
if(hours>40)
{
regpay=40*hrate;
overpay=(hours-40)*(1.5*hrate);
}
else
{
regpay=hours*hrate;
overpay=0;
}
totpay=regpay+overpay;
ded=0;
System.out.println("Want Medical insurance (Y/N)(1) Dental(2) Disability(3)");
ch=sc.next().charAt(0);
if(ch=='Y')
ded=ded+80;
System.out.println("Want Dental insurance (Y/N)");
ch=sc.next().charAt(0);
if(ch=='Y')
ded=ded+50;
System.out.println("Want Disability insurance (Y/N)");
ch=sc.next().charAt(0);
if(ch=='Y')
ded=ded+30;
System.out.println("Want Retirement Plan (Y/N)");
ch=sc.next().charAt(0);
if(ch=='Y')
ded=ded+(0.03*totpay);
pay=totpay-ded;
System.out.println("Hours Worked: " + hours);
System.out.println("Hourly Rate: " + hrate);
System.out.println("Regular Pay: " + regpay);
System.out.println("Overtime Pay: " + overpay);
System.out.println("Total Pay: " + totpay);
System.out.println("Total Deductions: " + ded);
System.out.println("Net Pay: " + pay);
}
}