Question

I would like help and there are three different classes in the coding..14.11 Prog11 Inheritance(PayrollOvertime) Create three files to submit: • Payroll class.java -Base class definition • PayrollEx: Enter the name, ID, pay rate, overtime pay rate, regular hours and overtime worked of an employee: Linda Smith 1234 20.5

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class ClientClass {
  
public static void main(String[] args) {

   Scanner input = new Scanner(System.in);
   System.out.println("Enter name , ID ,pay rate, overtime pay rate, regular hours and overtime worked of an employee");
  
  
   System.out.println("Enter name : ");
   String name = input.nextLine();
  
   System.out.println("Enter ID : ");
   int ID = input.nextInt();
  
   System.out.println("Enter pay rate : ");
   double payRate = input.nextDouble();

   System.out.println("Enter overtime pay rate : ");
   double overtimePayRate = input.nextDouble();
  
   System.out.println("Enter regular hours : ");
   double regularHr = input.nextDouble();  
  
   System.out.println("Enter overtime worked : ");
   double overtimeWorked = input.nextDouble();  
  
   PayrollOvertime overtime =new PayrollOvertime(name,ID,payRate,overtimeWorked);
   overtime.setHrWorked(regularHr);
   overtime.setOvertimeHrWorked(overtimeWorked);
   overtime.setOvertimePayRate(overtimePayRate);
  
   System.out.println("Record "+Payroll.getnOfObjs());
   System.out.println("Name: "+overtime.getName());
   System.out.println("ID: "+overtime.getID());
   System.out.println("Regular pay rate: $ "+overtime.getPayRate());
   System.out.println("Overtime pay rate: $ "+overtime.getOvertimePayRate());
   System.out.println("Regular hours worked: "+overtime.getHrWorked());
   System.out.println("Overtime hours worked: "+overtime.getOvertimeHrWorked());
   System.out.println("Gross pay: $ "+overtime.grossPay());
  
   PayrollOvertime overtime2 =new PayrollOvertime();
          
   System.out.println("Record "+Payroll.getnOfObjs());
   System.out.println("Name: "+overtime2.getName());
   System.out.println("ID: "+overtime2.getID());
   System.out.println("Regular pay rate: $ "+overtime2.getPayRate());
   System.out.println("Overtime pay rate: $ "+overtime2.getOvertimePayRate());
   System.out.println("Regular hours worked: "+overtime2.getHrWorked());
   System.out.println("Overtime hours worked: "+overtime2.getOvertimeHrWorked());
   System.out.println("Gross pay: $ "+overtime2.grossPay());
}
}

public class PayrollOvertime extends Payroll{

  
   private double overtimePayRate;
   private double overtimeHrWorked;
  


public PayrollOvertime(){
   super();
   overtimePayRate =22.5;
   overtimeHrWorked = 0;
  
}

public PayrollOvertime(String name, int ID,double payRate, double overtimePayRate) {
   super(name, ID, payRate);
   this.setOvertimePayRate(overtimePayRate);
  
}

public double getOvertimePayRate() {
   return overtimePayRate;
}

public void setOvertimePayRate(double overtimePayRate) {
   this.overtimePayRate = overtimePayRate;
}

public double getOvertimeHrWorked() {
   return overtimeHrWorked;
}

public void setOvertimeHrWorked(double overtimeHrWorked) {
   this.overtimeHrWorked = overtimeHrWorked;
}

public double grossPay() {
   return (hrWorked * payRate) + (overtimePayRate*getOvertimeHrWorked());
}
}

public class Payroll {

protected String name;
protected int ID;
protected double payRate;
protected double hrWorked;
protected static int nOfObjs;


public Payroll() { // constructor 1 ,default initialization
   name = "John Doe";
   ID = 9999;
   payRate = 15.0;
   hrWorked= 40;
   if(nOfObjs>0) {
       nOfObjs++;
   }else {
   nOfObjs = 0;
   }
     
}

public Payroll(String name, int ID, double payRate) {
   this.name = name;
   this.ID = ID;
   this.payRate = payRate;
   nOfObjs++;
}

public String getName() {
   return name;
}

public void setName(String name) {
   this.name = name;
}

public int getID() {
   return ID;
}

public void setID(int iD) {
   ID = iD;
}

public double getPayRate() {
   return payRate;
}

public void setPayRate(double payRate) {
   this.payRate = payRate;
}

public double getHrWorked() {
   return hrWorked;
}

public void setHrWorked(double hrWorked) {
   this.hrWorked = hrWorked;
}

public static int getnOfObjs() {
   return nOfObjs;
}

public static void setnOfObjs(int nOfObjs) {
   Payroll.nOfObjs = nOfObjs;
}
public double grossPay() {
   return hrWorked * payRate;
}
  
}

Add a comment
Know the answer?
Add Answer to:
I would like help and there are three different classes in the coding.. 14.11 Prog11 Inheritance(PayrollOvertime)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a Payroll class with the following fields:

    IN JAVADesign a Payroll class with the following fields:• name: a String containing the employee's name• idNumber: an int representing the employee's ID number• rate: a double containing the employee's hourly pay rate• hours: an int representing the number of hours this employee has workedThe class should also have the following methods:• Constructor: takes the employee's name and ID number as arguments• Accessors: allow access to all of the fields of the Payroll class• Mutators: let the user assign values...

  • Given attached you will find a file from Programming Challenge 5 of chapter 6 with required...

    Given attached you will find a file from Programming Challenge 5 of chapter 6 with required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: An empty string is given for the employee’s name. An invalid value is given to the employee’s ID number. If you implemented this field as a string, then an empty string could be invalid. If you implemented this field as a numeric variable, then a...

  • i am having trouble displaying results and displaying them evenly it is suppose to look like...

    i am having trouble displaying results and displaying them evenly it is suppose to look like this Enter the following data for employee 1: Employee ID: 1298 Hours worked: 35.8 Pay rate (per hour): 23.45 Enter the following data for employee 2: Employee ID: 1899 Hours worked: 34.5 Pay rate (per hour): 19.5 Enter the following data for employee 3: Employee ID: 4435 Hours worked: 30.5 Pay rate (per hour): 20.75 Enter the following data for employee 4: Employee ID:...

  • I was wondering if I could get some help with a Java Program that I am...

    I was wondering if I could get some help with a Java Program that I am currently working on for homework. When I run the program in Eclipse nothing shows up in the console can you help me out and tell me if I am missing something in my code or what's going on? My Code: public class Payroll { public static void main(String[] args) { } // TODO Auto-generated method stub private int[] employeeId = { 5658845, 4520125, 7895122,...

  • HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private...

    HospitalEmployee Inheritance help please. import java.text.NumberFormat; public class HospitalEmployee {    private String empName;    private int empNumber;    private double hoursWorked;    private double payRate;       private static int hospitalEmployeeCount = 0;    //-----------------------------------------------------------------    // Sets up this hospital employee with default information.    //-----------------------------------------------------------------    public HospitalEmployee()    { empName = "Chris Smith"; empNumber = 9999; hoursWorked = 0; payRate =0;               hospitalEmployeeCount++;    }       //overloaded constructor.    public HospitalEmployee(String eName,...

  • Must be written in java. Modularize the following code. //CIS 183 Lab 4 //Joseph Yousef import...

    Must be written in java. Modularize the following code. //CIS 183 Lab 4 //Joseph Yousef import java.util.*; public class SalaryCalc { public static void main(String [] args) { Scanner input = new Scanner(System.in); int sentinelValue = 1; //initializes sentinelValue value to 1 to be used in while loop while (sentinelValue == 1) { System.out.println("Enter 1 to enter employee, or enter 2 to end process: ");    sentinelValue = input.nextInt(); input.nextLine(); System.out.println("enter employee name: "); String employeeName = input.nextLine(); System.out.println("enter day...

  • C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab...

    C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab9b.cpp to the project. Copy and paste the code is listed below: Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information: Shift (an integer) Hourly pay rate (a double) // Specification file for the ProductionWorker Class #ifndef PRODUCTION_WORKER_H #define PRODUCTION_WORKER_H #include "Employee.h" #include <string> using namespace std; class ProductionWorker...

  • The following Java code outputs various amounts for a worker based on skill level, hours worked,...

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

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • J Inc. has a file with employee details. You are asked to write a C++ program...

    J Inc. has a file with employee details. You are asked to write a C++ program to read the file and display the results with appropriate formatting. Read from the file a person's name, SSN, and hourly wage, the number of hours worked in a week, and his or her status and store it in appropriate vector of obiects. For the output, you must display the person's name, SSN, wage, hours worked, straight time pay, overtime pay, employee status and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT