write in java and please code the four classes with the
requirements instructedimport java.util.ArrayList;
class Employee {
private String name;
private String department;
private String id;
private Address address;
private Contact contact;
// Default constructor. Set protected variables to
the empty string or 0
public Employee() {
name = "";
department = "";
id = "";
}
// Constructor with parameters to set the private
variables
public Employee(String name, String department, String
id,Address a, Contact c) {
this.name = name;
this.department = department;
this.id = id;
address=a;
contact=c;
}
public String getName() {
return name;
}
public String getDepartment() {
return department;
}
public String getId() {
return id;
}
public void setDepartment(String department)
{
this.department = department;
}
public double getWeeklyPay() {
return 0.0;
}
public String toString() {
return "Name: " + name + ",
Department: " + department + ", ID: " + id;
}
}
class Address{
private String streetAddress;
private String city;
private String state;
private String pinCode;
public Address(){}
public Address(String aStreetAddress, String aCity,
String aState, String aPinCode) {
super();
streetAddress =
aStreetAddress;
city = aCity;
state = aState;
pinCode = aPinCode;
}
@Override
public String toString() {
return "Address [streetAddress=" +
streetAddress + ", city=" + city + ", state=" + state + ",
pinCode="
+ pinCode + "]";
}
public String getStreetAddress() {
return streetAddress;
}
public void setStreetAddress(String aStreetAddress)
{
streetAddress =
aStreetAddress;
}
public String getCity() {
return city;
}
public void setCity(String aCity) {
city = aCity;
}
public String getState() {
return state;
}
public void setState(String aState) {
state = aState;
}
public String getPinCode() {
return pinCode;
}
public void setPinCode(String aPinCode) {
pinCode = aPinCode;
}
}
class Contact{
private String email;
private String phone;
Contact(){
}
public Contact(String aEmail, String aPhone) {
super();
email = aEmail;
phone = aPhone;
}
public String getEmail() {
return email;
}
public void setEmail(String aEmail) {
email = aEmail;
}
public String getPhone() {
return phone;
}
public void setPhone(String aPhone) {
phone = aPhone;
}
@Override
public String toString() {
return "Contact [email=" + email +
", phone=" + phone + "]";
}
}
class HourlyEmployee extends Employee {
private double hourlyRate;
/* FIXME(2) Complete the default constructor to set hourlyRate to 0.0 */
public HourlyEmployee() {
super();
hourlyRate = 0.0;
}
/*
* FIXME(3) Complete the argumented constructor to set
each field properly
*
* Note that you can call the superclass constructor to
initialize the
* fields defined in the superclass
*
* The second video in Canvas shows an example on
this.
*/
public HourlyEmployee(String name, String department,
String id, double rate,Address a , Contact c) {
super(name, department, id,a,c);
setHourlyRate(rate);
}
public double getHourlyRate() {
return hourlyRate;
}
public void setHourlyRate(double rate) {
hourlyRate = (rate < 0.0) ? 0.0 : rate;
}
@Override
public String toString() {
return "hourly employee: "
+ super.toString()
+ String.format(" hourly wage: $%.2f\n",
getHourlyRate());
}
}
class SalariedEmployee extends Employee {
private double annualSalary;
public SalariedEmployee() {
annualSalary=0;
}
public SalariedEmployee(String name, String
department, String id, double salary,Address a,Contact c) {
super(name, department,
id,a,c);
annualSalary=salary;
}
public double getAnnualSalary() {
return annualSalary;
}
public void setAnnualSalary(double salary) {
this.annualSalary = salary;
}
@Override
public double getWeeklyPay() {
return annualSalary / 52;
}
@Override
public String toString() {
return "Name : " + getName() + "
Department : " + getDepartment() + " ID : " + getId() + ", Annual
Salary : $"
+ getAnnualSalary();
}
}
public class HumanResource {
public static void main(String[] args) {
ArrayList<Employee> employees
= new ArrayList<Employee>();
HourlyEmployee e1 = new
HourlyEmployee("John Smith", "Sales", "jsmith1", 18.2,new
Address(),new Contact());
employees.add(e1);
SalariedEmployee e2 = new
SalariedEmployee("Amy Brown", "Marketing", "abrown3", 45000,new
Address(),new Contact());
employees.add(e2);
SalariedEmployee e3 = new
SalariedEmployee("Henry Chuck", "Accounting", "cchuck2",
50000.0,new Address(),new Contact());
employees.add(e3);
SalariedEmployee e4 = new
SalariedEmployee("Mary Miller", "IT", "mmiller5", 75000,new
Address(),new Contact());
employees.add(e4);
for (int i = 0; i <
employees.size(); i++) {
System.out.println(employees.get(i).getName() + " $" +
employees.get(i).getWeeklyPay());
}
}
}
write in java and please code the four classes with the requirements instructed You will be...
My Java code from last assignment:
Previous Java code:
public static
void main(String args[]) {
// While loop set-up
boolean flag = true;
while (flag) {
Scanner sc = new
Scanner(System.in);
// Ask user to enter employee number
System.out.print("Enter employee
number: ");
int employee_number = sc.nextInt();
// Ask user to enter last name
System.out.print("Enter employee last
name: ");
String last_name = sc.next();
// Ask user to enter number of hours worked
System.out.print("Enter number of
hours worked: ");
int hours_worked =...
My Java code from last assignment:
Previous Java code:
public static
void main(String args[]) {
// While loop set-up
boolean flag = true;
while (flag) {
Scanner sc = new
Scanner(System.in);
// Ask user to enter employee number
System.out.print("Enter employee
number: ");
int employee_number = sc.nextInt();
// Ask user to enter last name
System.out.print("Enter employee last
name: ");
String last_name = sc.next();
// Ask user to enter number of hours worked
System.out.print("Enter number of
hours worked: ");
int hours_worked =...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyEmployee that inherits from the Employee class. HourEmployee must use the inherited parent class variables and add in HourlyRate and HoursWorked. Your HourEmployee class should contain a constructor that calls the constructor from the...
Within c++ Create a simple Employee class with name, department, and title. Create an hourlyEmployee class (which inherits from the Employee class) for a basic payroll program to compute the net pay salary of hourly based employees. Your program should also find the average net pay for a small company. To define the class, include the appropriate data members, member functions, constructors, and access modifiers. For simplicity, use a constant tax rate of 30% to compute the tax amount. Employees...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings. Create another class HourlyEmployee that inherits from the abstract Employee class. HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings. Create another class HourlyEmployee that inherits from the abstract Employee class. HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...
Write a Java application with a class name of Payroll, for the “Travel Agency”, that willCalculate the weekly paycheck for both Salaried and Hourly employees. Salaried employees will be paid 1/52 of their annual pay minus 18% withheld for federal and state taxes, as well as 4% for retirement pension. Salaried employees do not collect overtime pay. There are two types of Hourly employees; permanent employees and temporary weekly employees. •Permanent weekly employees will be paid their hourly rate minus...
JAVA please: This lab has four parts: 1. Write a Person class. 2. Write a Student and Employee subclass to Person. 3. Write a Faculty and Staff subclass to Employee. 4. Write a program that creates an object of all of the above classes. Task 1 – The Person Class First, let us make a simple class titled Person. A person should include: 1. The class variables/attributes/properties: a. Name, b. Address, c. Phone number, d. And email address. 2. An...
In Java Kindly be sure to take in user input and store the 3 worker classes in an ArrayList Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class. HourlyWorker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your...
java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: • An empty string is given for the employee’s name. • An invalid value is given for the employee’s ID number. If you implemented this field as a string, then an empty string would be invalid. If you implemented this field as a numeric variable, then a negative number or...