Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

STEP 1: Understand the UML Class Diagram Use the following UML diagram to build

ID: 3655147 • Letter: S

Question

STEP 1: Understand the UML Class Diagram

Use the following UML diagram to build the class. The first section specifies the attributes. The second section specifies the behaviors, and the first character specifies the access modifier value, where:

STEP 2: Code the Employee Class

STEP 3: Code the Main Program

In the Main class, create code statements that perform the following operations. Be sure you follow proper commenting and programming styles (header, indentation, line spacing, etc.).

STEP 4: Compile and Test

When done, compile and run your code. Then, debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.

Your output should resemble the following:

STEP 1: Understand the UML Class Diagram

Explanation / Answer

/* you may also download the code from http://www.2shared.com/file/PHhGWPHB/Employee.html*/ import java.util.Scanner; public class Employee { String firstName; String lastName; String gender; int dependents; int annualSalary; Employee() { firstName = "not given"; lastName = "not given"; gender = "U"; dependents = 0; annualSalary = 20000; } Employee(String fname, String lname, String gen, int dep, int sal) { firstName = fname; lastName = lname; gender = gen; dependents = dep; annualSalary = sal; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public int getDependents() { return dependents; } public void setDependents(int dependents) { this.dependents = dependents; } public int getAnnualSalary() { return annualSalary; } public void setAnnualSalary(int annualSalary) { this.annualSalary = annualSalary; } double calculatePay() { return (annualSalary / 52); } void displayEmployee() { System.out.println("Employee's First Name :" + getFirstName()); System.out.println("Employee's Last Name :" + getLastName()); System.out.println("Employee's Gender :" + getGender()); System.out.println("Employee's Dependents :" + getDependents()); System.out.println("Employee's Annual Salary :" + getAnnualSalary()); System.out.println("Employee's weekly pay :" + calculatePay()); } public static void main(String[] args) { Employee emp1 = new Employee(); Scanner input = new Scanner(System.in); System.out.println("Enter the employee's first name"); emp1.setFirstName(input.nextLine()); System.out.println("Enter the employee's last name"); emp1.setLastName(input.nextLine()); System.out.println("Enter the employee's gender"); emp1.setGender(input.nextLine()); System.out.println("Enter the employee's Dependents"); emp1.setDependents(input.nextInt()); System.out.println("Enter the employee's Annual Salary"); emp1.setAnnualSalary(input.nextInt()); emp1.displayEmployee(); Employee emp2 = new Employee(emp1.getFirstName(), emp1.getLastName(), emp1.getGender(), emp1.getDependents(), emp1.getAnnualSalary()); emp2.displayEmployee(); } }