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

employees.txt Purpose: Build an application to calculatc an Fmploycc\'s Gross Pa

ID: 3732099 • Letter: E

Question

employees.txt

Purpose: Build an application to calculatc an Fmploycc's Gross Pay use Java OO GUT Design Problem: Build a GUI application that would ullow the user to calculate an Employee's Gruss Pay. The userwl enler the employee's id number, pay-perid end-date and hours worked. The program will read the input file to ohtain the employee name and hourly pay rt. The program then calculates and displays he Fmploycc's Full Name and Gross Pay for the pay period (see both inputs and outputs listed in the table helow). Assumptions; Gross Pay-( Regular hourspuy rute) : (Over .iime hours* puy rute 1.5) Regular hours are less than or equul to 40 L anguage: JAVA (Ohject-nriented and IT) Input Tields Duta Type Icurs Wocked Double 41.5 File Employse r String Name String Read Cmployee rile Display Output Clear Clear Inpur Output centrul fur the next Employee cr To start ovec Output Regular llours Regular Py Over Time Advupc

Explanation / Answer

import java.lang.*;

import java.io.*;

class Employee

{

                String emp_id;

                String emp_name;

                String pay_period;

                double hours_worked;

                int hourlypay;

                Employee (String id, String name, int hp, double hw )

                {

                                emp_id=id;

                                emp_name=name;

                                hourlypay=hp;

                                hours_worked=hw;

                }

                void disp()

                {

                                float gross_sal=(hours_worked * hp);

                                if (hours_worked>40)

                                {

                                double hw1= hours_worked – 40;            //calculate extra hours worked

                                gross_sal= gross_sal + (hw1 * hp * 1.5);

                                }

                                System.out.println ("Employee Id= "+emp_id);

                                System.out.println ("Emplyee Name= "+emp_name);

                                System.out.println ("Gross Salary= "+gross_sal);

                }

}

class Emp

{

                public static void main(String args[]) throws IOException

                {

                                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

                                System.out.println ("Enter Emp id");

                                int id = Integer.parseInt(br.readLine());

                                System.out.println ("Enter Emp Name");

                                String name = br.readLine();

                                System.out.println ("Enter hourly pay and hours worked");

                                int hp = int.parseint(br.readLine());

                                double hw = double.parsedouble(br.readLine());

                                Employee obj= new Employee(id, name, hp, hw);

                                obj.disp();

                }

}

ALGORITHM

Step 1: Read the employee id, employee name, hours worked, hourly pay from user.

Step 2: if hours worked is less than equal to 40 then calculate:

gross pay= hours_worked * hourly pay

Step 3: if hours_worked is greater than 40 calculate overtime hours and calculate

gross pay= gross pay + (overtime hours worked * hourly pay * 1.5)

Step 4: End.