Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, this program is done in JAVA . Description of the Assignment ShiftSupervisor Class: In a particular factory, a shift supervisor is a salaried employee

Hello, this program is done in JAVA.

Description of the Assignment

ShiftSupervisor Class: In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Design a ShiftSupervisor class that extends the Employee.java class you can download by clicking on the file name. The ShiftSupervisor class should have a field that holds the annual salary and a field that holds the annual production bonus that a shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the class by writing a program, ShiftSupervisorDemo.java for instance, that uses a ShiftSupervisor object. TIP: Your ShiftSupervisor class should inherit from the Employee class which you have downloaded. You will have two private fields: salary and bonus in you ShiftSupervisor class. They are both Double data type. You will also have constructors in your ShiftSupervisorclass that will call its super, Employee class's constructors accordingly. You may have tow constructors, one with parameters, one without. Your ShiftSupervisorDemo.java will have a main() method. Some ShiftSupervisor objects will be created in this main() method. You ma want to display these new created ShiftSupervisor object's information.

I have completed all my code, however there is something wrong with my output.

Here is my code:

Employee.java

import java.io.*;

import java.util.Scanner;

public class Employee { private String Empname; // Employee name private String Empnumber; // Employee number private String Hiredate; // Employee hire date

public Employee(String Empname, String Empnumber, String Hiredate) { String setName = Empname; String setNumber = Empnumber; String setHireDate = Hiredate; }

public String getName() { return Empname; } public String getNumber() { return Empnumber; } public String getHireDate() { return Hiredate; } public void setName(String n) { Empname = n; } public void setNumber(String num) { Empnumber = num; } public void setHireDate(String h) { Hiredate = h; }

}

ShiftSupervisor.java

class ShiftSupervisor extends Employee{

private double annualsalary; private double annualproduction;

public ShiftSupervisor(String Empname, String Empnumber, String Hiredate, double annualsalary, double annualproduction) { super(Empname,Empnumber,Hiredate); setAnuSal(annualsalary); setAnuPro(annualproduction); }

public double getAnuSal() { return annualsalary; }

public double getAnuPro() { return annualproduction; } public void setAnuSal(double s) { annualsalary = s; } public void setAnuPro (double p) { annualproduction = p; }

@Override public String toString() { return "Name:"+getName()+" EmpID:"+getNumber()+" Hire Date:"+getHireDate()+" Annual Salary:"+annualsalary+" Production"+annualproduction; } }

employeeDemo.java

public class employeeDemo { public static void main (String[] args) { String name,id,date; double sal,prod; //create scanner object Scanner keyboard = new Scanner(System.in); System.out.println("Enter Name:"); name=keyboard.nextLine(); System.out.println("Enter id:"); id=keyboard.nextLine(); System.out.println("Enter Hire Date:"); date=keyboard.nextLine(); System.out.println("Enter Annual:"); sal=keyboard.nextDouble(); System.out.println("Enter production:"); prod=keyboard.nextDouble(); //instantiating object ShiftSupervisor pw = new ShiftSupervisor(name,id,date,sal,prod); //output data System.out.println("Employee Details: "+pw); } }//function definition

Here is my output

image text in transcribed

image text in transcribed

Notice at the end, it returns Name, EmpID, and Hire Date as "null."

Can someone please fix this for me?

Enter Name Tony Enter id 045A21BCT Enter Hire Date 2/6/2010 Enter Annual 50000 Enter production: 50

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions