Question: This assignment will use the Employee, Name, Address, and Date classes which you developed for Module Assignment 6. You are to incorporate any fies indicated

This assignment will use the Employee, Name, Address, and Date classes which you developed for Module Assignment 6. You are to incorporate any fies indicated in your Module 6 Assignment feedback for this assignment.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 gets paid at 1.5 times their hourly pay rate for all hours over 40.

You will decide how to implement constructors, getters, setters, and any other methods that might be necessary. Implement the classes, and write a test program that creates (internally, do not prompt the user) a salaried employee and two hourly employees. One of the hourly employees should have hours worked set to less than or equal to 40 and one should have hours worked set to more than 40.

Create a 3-element Employee array and place the three Employees in this array. The test program should display all attributes for the three employees eitracted from the array.

These are my previous classes. Any help will be appreciated.

import java.util.Scanner; public class EmployeeDB { public static void main(String[] args) {

Scanner input = new Scanner(System.in); System.out.println("Welcome to employee database"); System.out.println("Follow the instructions to upload employee information") ; System.out.println("Please enter the number of employees you would like to save:"); int n = input.nextInt();

Employee [] employees = new Employee [n];

for (int i = 0; i < n; i++) { System.out.println("First Name:" ); String firstName = input.next();

System.out.println("Last Name:" ); String lastName = input.next(); System.out.println("Street Name:"); String street = input.next(); System.out.println("Street Number:"); int streetnum = input.nextInt(); System.out.println("City: "); String city = input.next(); System.out.println("State:"); String state = input.next(); while (state.length() != 2) { System.out.println("Please enter 'State' in two letter format:"); state = input.next(); } System.out.println("Zip Code: " ); String zip = input.next(); while (zip.length() !=5) { System.out.println("Please enter a 5 digit zip code: "); zip = input.next(); } System.out.println("Month Hired: " ); int month = input.nextInt(); while (month < 1 ^ month > 12) { System.out.println("Please enter a valid value for 'Month': "); month = input.nextInt(); } System.out.println("Day Hired: " ); int day = input.nextInt(); while (day < 1 ^ day > 31) { System.out.println("Please enter a valid value for 'Day': "); day = input.nextInt(); } System.out.println("Year Hired: " ); int year = input.nextInt() ; while (year > 2018) { System.out.println("Please enter a valid value for year: "); year = input.nextInt(); } if (n>1) System.out.print("Done! Now enter the info for Employee #" + (i+2)); System.out.println(); Name Name = null; Name = new Name(firstName, lastName); Address address = new Address(streetnum, street, city, state, zip); Date date = new Date(month, day, year);

Employee employee = new Employee(i, Name, address, date);

employees[i] = employee; /* Name, Address, Employee and Date classes are defined. On the code below, values are called from these classes. */ } for(Employee employee : employees) { System.out.println(); System.out.print("Employee No:" + employee.getNo() + " "); System.out.print("First Name: " +employee.getName().getFirstName() + " "); System.out.println("Last Name:" +employee.getName().getLastName()); System.out.print("Address:" + employee.getAddress().getStreet() + " "); System.out.print(employee.getAddress().getStreetnum() + " "); System.out.print(employee.getAddress().getCity() + " "); System.out.print(employee.getAddress().getState() + " "); System.out.println(employee.getAddress().getZip()); System.out.print("Date Hired:" + employee.getDate().getMonth() + "/"); System.out.print(employee.getDate().getDay() + "/"); System.out.println(employee.getDate().getYear()); System.out.println(); } input.close(); } }

class Employee { private int no; private Name name; private Address address; private Date date; Employee(int id, Name name, Address address, Date date) { setId(id); setName(name); setAddress(address); setDate(date); } public void setId(int no) { this.no = no; } public void setName(Name name) { this.name = name; } public void setAddress(Address address) { this.address = address; } public void setDate(Date date) { this.date = date; } public int getNo() { return (no+1); } public Name getName() { return name; } public Address getAddress() { return address; } public Date getDate() { return date; } }

class Name { private String firstName; private String lastName; Name(String firstName, String lastName) { setFirstName(firstName); setLastName(lastName); } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } }

class Address { private int streetnum; private String street; private String city; private String state; private int zip;

Address (int streetnum, String street, String city, String state, String zip) { setStreet(street); setStreetnum(streetnum); setCity(city); setState(state); setZip(zip); } public void setStreet(String street) { this.street = street; } public void setStreetnum(int streetnum) { this.streetnum = streetnum; } public void setCity(String city) { this.city = city; } public void setState(String state) { this.state = state; } public void setZip(String zip) { this.zip = Integer.parseInt(zip); } public String getStreet() { return street; } public int getStreetnum() { return streetnum; } public String getCity() { return city; } public String getState() { return state; } public int getZip() { return zip; }

}

class Date { private int month; private int day; private int year; Date (int month, int day, int year) { setMonth(month); setDay(day); setYear(year); } public void setMonth(int month) { this.month = month; } public void setDay(int day) { this.day = day; } public void setYear(int year) { this.year = year; } public int getMonth() { return month; } public int getDay() { return day; } public int getYear() { return year; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!