1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Schach [20]
3 years ago
12

Design two subclasses of Employee…SalariedEmployee and HourlyEmployee. A salaried employee has an annual salary attribute. An ho

urly employee has an hourly pay rate attribute, an hours worked attribute, and an earnings attribute. An hourly employee that works more than 40 hours gets paid at 1.5 times their hourly pay rate. You will decide how to implement constructors, getters, setters, and any other methods that might be necessary. 1. (20 points) Draw a UML diagram for the classes. 2. (80 points) Implement the classes, and write a test program that creates a salaried employee and two hourly employees. One of the hourly employees should have hours worked set to less than 40 and one should have hours worked set to more than 40. The test program should display all attributes for the three employees. To keep things simple, the employee classes don’t need to do any editing.
public class Employee
{
private int empID;
Address address;
Name name;
Date date;

public Employee()
{
}

public Employee(int empID)
{
this.empID = empID;
}

public int getEmpID()
{
return empID;
}

public void setEmpID(int empID)
{
this.empID = empID;
}

public Address getAddress()
{
return address;
}

public void setAddress(Address address)
{
this.address = address;
}

public Name getName()
{
return name;
}

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

public Date getDate()
{
return date;
}

public void setDate(Date date)
{
this.date = date;
}

}
Computers and Technology
1 answer:
avanturin [10]3 years ago
7 0

Answer:

Complete answer to above question is given below.

Explanation:

Employee.java

import java.util.Date;

public class Employee

{

private int empID;

private Address address;

private Name name;

private Date date;

public Employee()

{

}

public Employee(int empID)

{

this.empID = empID;

}

public int getEmpID()

{

return empID;

}

public void setEmpID(int empID)

{

this.empID = empID;

}

public Address getAddress()

{

return address;

}

public void setAddress(Address address)

{

this.address = address;

}

public Name getName()

{

return name;

}

public void setName(Name name)

{

this.name = name;

}

public Date getDate()

{

return date;

}

public void setDate(Date date)

{

this.date = date;

}

}

Name.java

public class Name {

private String name;

public Name(String name) {

super();

this.name = name;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

}

Address.java

public class Address {

private String addr;

public Address(String addr) {

super();

this.addr = addr;

}

public String getAddr() {

return addr;

}

public void setAddr(String addr) {

this.addr = addr;

}

}

SalariedEmployee.java

public class SalariedEmployee extends Employee {

private double annualSalary;

public SalariedEmployee(double annualSalary) {

super();

this.annualSalary = annualSalary;

}

public double getAnnualSalary() {

return annualSalary;

}

public void setAnnualSalary(double annualSalary) {

this.annualSalary = annualSalary;

}

}

HourlyEmployee.java

public class HourlyEmployee extends Employee {

private double hourlyrate;

private double hours_worked;

private double earnings;

public HourlyEmployee(double hourlyrate, double hours_worked) {

super();

this.hourlyrate = hourlyrate;

this.hours_worked = hours_worked;

}

public double getEarnings()

{

if(hours_worked<=40)

{

earnings=hours_worked*hourlyrate;

}

else if(hours_worked>40)

{

earnings=40*hourlyrate+(hours_worked-40)*hourlyrate*1.5;

}

return earnings;

}

public double getHourlyrate() {

return hourlyrate;

}

public void setHourlyrate(double hourlyrate) {

this.hourlyrate = hourlyrate;

}

public double getHours_worked() {

return hours_worked;

}

public void setHours_worked(double hours_worked) {

this.hours_worked = hours_worked;

}

public void setEarnings(double earnings) {

this.earnings = earnings;

}

Test.java

import java.util.Date;

public class Test {

public static void main(String[] args) {

System.out.println("_____Salaried Employee_____");

SalariedEmployee se=new SalariedEmployee(50000);

se.setEmpID(1234);

se.setName(new Name("Williams"));

se.setAddress(new Address("4,Richmond Street"));

se.setDate(new Date("Oct-11-2014"));

System.out.println("Employee Id :"+se.getEmpID());

System.out.println("Employee Name :"+se.getName().getName());

System.out.println("Employee Address :"+se.getAddress().getAddr());

System.out.println("Joining Date :"+se.getDate());

System.out.println("The Annual Salary :"+se.getAnnualSalary());

System.out.println("\n_____Hourly Employee_____");

HourlyEmployee he1=new HourlyEmployee(8.5,39);

he1.setEmpID(4567);

he1.setName(new Name("Kane"));

he1.setAddress(new Address("5,lake View Road"));

he1.setDate(new Date("Nov-12-2015"));

System.out.println("Employee Id :"+he1.getEmpID());

System.out.println("Employee Name :"+he1.getName().getName());

System.out.println("Employee Address :"+he1.getAddress().getAddr());

System.out.println("Joining Date :"+he1.getDate());

System.out.println("The Earnings Of An HourlyEmployee :"+he1.getEarnings());

System.out.println("\n_____Hourly Employee_____");

HourlyEmployee he2=new HourlyEmployee(9.5,47);

he2.setEmpID(1111);

he2.setName(new Name("John"));

he2.setAddress(new Address("17,Villey Parley Street"));

he2.setDate(new Date("Dec-13-2011"));

System.out.println("Employee Id :"+he2.getEmpID());

System.out.println("Employee Name :"+he2.getName().getName());

System.out.println("Employee Address :"+he2.getAddress().getAddr());

System.out.println("Joining Date :"+he2.getDate());

System.out.println("The Earnings Of An HourlyEmployee :"+he2.getEarnings());

}

}

Output:

_____Salaried Employee_____

Employee Id :1234

Employee Name :Williams

Employee Address :4,Richmond Street

Joining Date :Sat Oct 11 00:00:00 IST 2014

The Annual Salary :50000.0

_____Hourly Employee_____

Employee Id :4567

Employee Name :Kane

Employee Address :5,lake View Road

Joining Date :Thu Nov 12 00:00:00 IST 2015

The Earnings Of An HourlyEmployee :331.5

_____Hourly Employee_____

Employee Id :1111

Employee Name :John

Employee Address :17,Villey Parley Street

Joining Date :Tue Dec 13 00:00:00 IST 2011

The Earnings Of An HourlyEmployee :479.75

You might be interested in
When widgets, or portable chunks of code, are embedded on html pages and thereby help increase the functionality of those pages,
Anna11 [10]
<span>When widgets, or portable chunks of code, are embedded on html pages and thereby help increase the functionality of those pages, consumers embrace one of the greatest virtues of social media known as Collaboration.</span>
5 0
3 years ago
You can use a(n) ____ to visually separate related controls from other controls on the form.
maksim [4K]

Answer:

The correct answer to the following question will be Group Box.

Explanation:

Group Box:

  • A type container that contains many types of controls that are usually related to each other in the form.
  • It usually provides the identified grouping for other controls.
  • used for the subdivision of the forms.
  • Separation of the controls can be done with the help of grouping by group box.

5 0
2 years ago
Finish the code to search for a 7 in the array.
guapka [62]

Answer:

The complete code is as follows:

from array import *

myArr = array('f',[3, 5, 7,3, 10])

location = myArr.index(7)

print(str("7")+" is at position "+str(location+1))

Explanation:

I made corrections to the third line of the code and I added a line

This line gets the index of 7 from the array myArr using the index keyword

location = myArr.index(7)

This line prints the position of the 7 in the array

print(str("7")+" is at position "+str(location+1))

8 0
2 years ago
You completed the wireframe step of mobile app development. Which statement is true about this step?
UkoKoshka [18]

The statement that is true about this step is that:

  • You have drawn pictures of what your screens will look like and identified the input-process-output that occurs on each screen.
  • In this step, you defined your target audience and main goal.

<h3>How wireframe is made to create mobile apps?</h3>

The Steps for wireframing are:

  • Begin by mapping out a specific user flow.
  • Do a Sketch of the core part and then begin wireframing by setting a Mobile Frame.
  • Se the layout using boxes and use design patterns.
  • Make sure to link the pages together to create a flow.

Note that The statement that is true about this step is that:

  • You have drawn pictures of what your screens will look like and identified the input-process-output that occurs on each screen.
  • In this step, you defined your target audience and main goal.

Learn more about wireframe  from

brainly.com/question/12734458

#SPJ1

5 0
2 years ago
Nate finishes his application letter and wants to save it as a template. Which type of file will it be?
Dominik [7]

dot.x you silly gooses hehehe

6 0
3 years ago
Read 2 more answers
Other questions:
  • The system administrator in your office quits unexpectedly in the middle of the day. It's quickly apparent that he changed the s
    10·1 answer
  • Which of the following is NOT a web browser?<br> Safari<br> Chrome<br> Bing<br> Firefox
    8·2 answers
  • What is the difference between a Network Diagram and a Wiring Semantic?
    5·1 answer
  • your computer is running exceptionally slow. not only does it take the operating system a long time to start, but programs also
    11·1 answer
  • What are examples of templates the Input Mask Wizard offers? Check all that apply.
    12·2 answers
  • (ANSWER!)
    8·2 answers
  • Does anyone play genshin impact here?
    12·2 answers
  • How do operating system work?
    5·1 answer
  • Which is the least technically experienced technical support group?
    7·1 answer
  • In a typical office, biometric authentication might be used to control access to employees and registered visitors only. We know
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!