Question

You will be writing a multiclass user management system using the java. Create a program that...


You will be writing a multiclass user management system using the java. Create a program that
implements a minimum of four classes. The classes must include:
1.
Employee Class with the attributes of Employee ID, First Name, Middle
Initial, Last
Name, Date of Employment.
2.
EmployeeType
Class that has two instances of EmployeeType objects
,
salaried a
nd
hourly. Each object will have methods that calculates
employee’s
payroll (
you
may use
attributes from Assignment 2), but you must handle the calculation in a method. Assume
that you have hourly employees who work overtime and if the hours they worked ove
r 40
hours, they must be paid one
-
and
-
one
-
half
times the regular rate of
pay
for all hours
worked over 4o hours. Both federal and state tax must be calculated
3.
Address Class that handles address of the employee: attributes include street address,
city,
state, zip code,
4.
Contact Class
-
The Contact class will have email and phone attributes

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program in java

Note total 5 classes in a package called empmngt

1. Employee.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package empmngt;

import java.util.Date;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author SuNiL
*/
//class definition
public class Employee {
    //declaring attribute
    String empFirstName,empMiddleName,empLastName;
    int empID;
    Date empDate;
    //constructor

    public Employee(String empFirstName, String empMiddleName, String empLastName, int empID, Date empDate) {
        this.empFirstName = empFirstName;
        this.empMiddleName = empMiddleName;
        this.empLastName = empLastName;
        this.empID = empID;
        this.empDate = empDate;
    }

  
    //getter and setter methods
    public String getEmpFirstName() {
        return empFirstName;
    }

    public void setEmpFirstName(String empFirstName) {
        this.empFirstName = empFirstName;
    }

    public String getEmpMiddleName() {
        return empMiddleName;
    }

    public void setEmpMiddleName(String empMiddleName) {
        this.empMiddleName = empMiddleName;
    }

        public String getEmpLastName() {
        return empLastName;
    }

    public void setEmpLastName(String empLastName) {
        this.empLastName = empLastName;
    }
  
    public int getEmpID() {
        return empID;
    }

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

    public Date getEmpDate() {
        return empDate;
    }

    public void setEmpDate(Date empDate) {
        this.empDate = empDate;
    }  
}

2. EmpPayroll.java

package empmngt;

//declaring class
public class EmpPayroll {
    //variable declaration
    String type=null;
    double hourWorked=0, payRate=0, salary=0, tax=0, netinc=0, totSalary=0, totTax=0, totPay=0;

    public EmpPayroll(String type) {
        this.type=type;
      
    }
  
    double findSalary(){
        if(type.equalsIgnoreCase("salaried")){
            salary=10000;
        }
        else{
            if(this.hourWorked<=40){
                salary=hourWorked*payRate;
            }
            else{
                salary=40*payRate+((hourWorked-40)*(1.5*payRate));
            }          
        }
        return salary;
    }
    void findTaxes(){
        if(salary<=250.00){
            tax=salary*18/100;
        }
        else if(salary<=550.00){
            tax=salary*23/100;
        }
        else if(salary<=1100.00){
            tax=salary*28/100;
        }
        else{
            tax=salary*33/100;
        }
    }
    void findNetIncome(){
        netinc=salary-tax;
    }
    String displayPayroll(){
        if(type.equalsIgnoreCase("salaried")){
            return "\nTotal Salary: "+salary+"\n Total Tax: "+tax+"\nTotal Payroll: "+netinc;
        }
        else{
            return "Hours: "+hourWorked+"\nRate of pay: "+payRate+"\nRSalary: "+salary+"\nTax: "+tax+"\nNet income: "+netinc;
        }
      
    }
}

3. EmpAddress.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package empmngt;

/**
*
* @author SuNiL
*/
public class EmpAddress {
    String street, city, state;
    int zipCode;
    //constructor
    public EmpAddress(String street, String city, String state, int zipCode) {
        this.street = street;
        this.city = city;
        this.state = state;
        this.zipCode = zipCode;
    }

    //getter and setter methods
    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public int getZipCode() {
        return zipCode;
    }

    public void setZipCode(int zipCode) {
        this.zipCode = zipCode;
    }
  
}

4. EmpContacts.java

package empmngt;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author SuNiL
*/
public class EmpContacts {
    String email;
    int phone;

    public EmpContacts(String email, int phone) {
        this.email = email;
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getPhone() {
        return phone;
    }

    public void setPhone(int phone) {
        this.phone = phone;
    }
  
  
}

5. EmpDriverClass.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package empmngt;

import java.util.Date;

/**
*
* @author SuNiL
*/
public class EmpDriverClass {
    public static void main(String[] args) {
        //creating objects
        Employee em=new Employee("Peter", "J", "Robert", 101, new Date("22/04/1987"));
        EmpPayroll ep=new EmpPayroll("Salaried");
        EmpAddress ea=new EmpAddress("22 smith", "Reo", "Costa", 212312);
        EmpContacts emc=new EmpContacts("email", 1234567899);
        ep.findSalary();
        ep.findTaxes();
        ep.findNetIncome();
        //printing details
        System.out.println("Employee details are as follows: ");
        System.out.println("Employee ID: "+em.empID);
        System.out.println("Employee Name: "+em.empFirstName+" "+em.empMiddleName+" "+em.empLastName);
        System.out.println("Employee Joining date: "+em.empDate);
        System.out.println("Employer type: "+ep.type);
        System.out.println("Employee salary: "+ep.salary);
        System.out.println("Employee tax: "+ep.tax);
        System.out.println("Employee net income: "+ep.netinc);
        System.out.println("Employee address: "+ea.street+" "+ea.city+" "+ea.state+" "+ea.zipCode);
        System.out.println("Employee email: "+emc.email);
        System.out.println("Employee phone: "+emc.phone);
    }
}

Output:

Add a comment
Know the answer?
Add Answer to:
You will be writing a multiclass user management system using the java. Create a program that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT