Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class employee_Detail { public static class Name { public String first= ; public String last= ; public Name() { first= ; last

image text in transcribed

import java.util.Scanner;

public class employee_Detail {

public static class Name { public String first=" "; public String last=" "; public Name() { first=" "; last =" "; } public String getFirst() { return first; } public String getLast() { return last; } public void setName(String first,String last) { this.first = first; this.last = last; } } public static class Date { public int month=0; public int day=0; public int year=0; public Date() { month=0; day=0; year=0; } public int getMonth() { return month; } public int getDay() { return day; } public int getYear() { return year; } public void setDate(int month,int day,int year) { this.month=month; this.day =day; this.year =year; } } public static class Address { public String street=" "; public String city=" "; public String state=" "; public int zip=0; public Address() { street=" "; city=" "; state=" "; zip=0; } public String getStreet() { return street; } public String getCity() { return city; } public String getState() { return state; } public int getZip() { return zip; } public void setAddress(String street,String city,String state,int zip) { this.street=street; this.city =city; this.state =state; this.zip =zip; } } public static class Employee { private int EmpNumb=0; private Name EmpName; private Address EmpAddress; private Date HireDate; public Employee() { EmpNumb=0; EmpName=new Name(); EmpAddress=new Address(); HireDate =new Date(); } public int getEmpNumb() { return EmpNumb; } public Name getEmpName() { EmpName.first=EmpName.getFirst(); EmpName.last =EmpName.getLast(); return EmpName; } public Address getEmpAddress() { EmpAddress.street=EmpAddress.getStreet(); EmpAddress.city =EmpAddress.getCity(); EmpAddress.state =EmpAddress.getState(); EmpAddress.zip =EmpAddress.getZip(); return EmpAddress; } public Date getHireDate() { HireDate.month=HireDate.getMonth(); HireDate.day =HireDate.getDay(); HireDate.year =HireDate.getYear(); return HireDate; } public void setEmpId(int Id) { EmpNumb=Id; } public void setEmpName(String first,String last) { EmpName.setName(first,last); } public void setHireDate(int month,int day,int year) { HireDate.setDate(month, day, year); } public void setEmpAddress(String street,String city,String state,int zip) { EmpAddress.setAddress(street, city, state, zip); } } public static void main(String[] args) { System.out.println("Enter the Number of Employee: "); Scanner scnr = new Scanner(System.in); int n=scnr.nextInt(); System.out.println("Enter the Data in Employee Array "); int Id; String first,last; int month,day,year; String street,city,state; int zip; Employee []EmpArr; EmpArr=new Employee[n]; for(int i=0;i

}

Using the Employee class below, design two sub-classes of Employee... SalariedEmployee and HourlyEmployee. A salaried employee has an annual salary attribute. An hourly employee has an hourly pay rate attribute, an hours worked attribute, and an earnings attribute. An hourly employee that works more than 40 hours in a week gets paid at 1.5 times their hourly pay rate for the hours over 40 hours. You will decide how to implement constructors, getters, setters, and any other methods that might be necessary. 1. Draw a UML diagram for the classes. 2. 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<>

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

Question

Question Can any type of stock or securities be used in an ESOP?

Answered: 1 week ago

Question

Question Can a self-employed person adopt a money purchase plan?

Answered: 1 week ago