Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Employee { private String empID; private String name; private String department; private double salary; private String designation; public Employee() { empID = null;

public class Employee

{

private String empID;

private String name;

private String department;

private double salary;

private String designation;

public Employee()

{

empID = null;

name = null;

department = null;

salary = 0.0;

designation = null;

}

public Employee(String empID, String name, String department, double salary, String designation)

{

this.empID = empID;

this.name = name;

this.department = department;

this.salary = salary;

this.designation = designation;

}

public void setEmpID(String empID)

{

this.empID = empID;

}

public void setName(String name)

{

this.name = name;

}

public void setDepartment(String department)

{

this.department = department;

}

public void setSalary(Double salary)

{

this.salary = salary;

}

public void setDesignation(String designation)

{

this.designation = designation;

}

public String getEmpID()

{

return empID;

}

public String getName()

{

return name;

}

public String getDepartment() {

return department;

}

public double getSalary() {

return salary;

}

public String getDesignation() {

return designation;

}

public double addBonus()

{

return salary + 200;

}

public int calcDeduction(int present)

{

int days= 20;

return days - present;

}

public void display()

{

System.out.println("Employee ID :" + empID);

System.out.println("Employee name : " + name);

System.out.println("Department name : " + department);

System.out.println("Salary :" + salary);

System.out.println("Designation : " + designation);

System.out.println("Salary after adding the bonus is : " +addBonus());

System.out.println("");

package Assignment4;

public class Manager extends Employee

{

private int bonus= 300;

private int days= 20;

public Manager()

{

super();

}

public Manager(String empID, String name, String department, double salary, String designation)

{

super(empID,name,department,salary,designation);

}

public double addBonus()

{

return super.getSalary()+ bonus;

}

public int calcDeduction(int present)

{

int absent = days - present;

return (int) addBonus()* absent/days;

}

}

public class Clerk extends Employee

{

private int bonus = 100;

private int days= 20;

public Clerk()

{

super();

}

public Clerk(String empID, String name, String department, double salary, String designation)

{

super(empID,name,department,salary,designation);

}

public double addBonus()

{

return super.getSalary() + bonus;

}

public int calcDeduction(int present)

{

int absent = days - present;

return (int) addBonus()* absent/days;

}

}

}

} import java.util.Scanner;

public class MainDemo

{

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

Employee emp1 = new Manager("E001","Mark","HR",15000.0,"Manager");

emp1.display();

Employee emp2 = new Manager("E012","Peter","R&D",15000.0,"Manager");

emp2.display();

Employee emp3 = new Clerk("E056","Samual","Accounts",10000.0,"Clerk");

emp3.display();

Employee emp4 = new Clerk("E089","Thomas","Accounts",10000.0,"Clerk");

if(!emp1.getDesignation().equals(emp3.getDesignation()))

{

System.out.println(emp1.getName() + " and " + emp3.getName() + " have different Designations ");

}

Employee worker[] = {emp1,emp2,emp3,emp4};

int present= 0;

int deduction[] = new int [4];

for(int i=0; i

{

System.out.println("Enter the number of days Employee " + worker[i].getEmpID()+ " is Present out of 20 :");

present = scan.nextInt();

for(int j=0; j

{

while(present > 20)

{

System.out.println("Error days have to be equal or less than 20");

System.out.println("Please re-type the number of hours for the employee " + worker[i].getEmpID());

present = scan.nextInt();

}

}

deduction[i] = worker[i].calcDeduction(present);

}

System.out.println("Employee ID\t" + "Present " + "Absent " + "\tDeductions" );

for (int row = 0; row

{

System.out.println(worker[row].getEmpID() + "\t\t" + present + "\t" + (20-present) + "\t" + deduction[row]);

}

}

}

Use my code to complete this assignment well just the last part that involves the array.

Make it so that it looks the same as this output

image text in transcribed

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. What would you do now if you were Mel Fisher?

Answered: 1 week ago

Question

14.3 Explain WHMISlegislation.

Answered: 1 week ago