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

Scenario and Summary: We begin our investigation of object-oriented programming

ID: 3655110 • Letter: S

Question

Scenario and Summary:

We begin our investigation of object-oriented programming by creating an object-oriented program with a class called Employee. You will create two objects based on the Employee class, along with a class that contains the main method. The attributes, constructors, and methods for this class must satisfy the requirements in Steps 1 through 3. After you create the objects, you will prompt the user for information and then display it.

We will want to ensure that this first class is well-constructed and tested since we will extend this class in Labs 3 through 6.

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/FT4GX6XR/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(); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote