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

class Employee: import java.util.Scanner; public class Employee { private String

ID: 3911131 • Letter: C

Question

class Employee:

import java.util.Scanner;

public class Employee

{

private String ssn;

private String name;

private String position;

private int salary;

public Employee(String ssn, String name, String position, int salary)

{

this.salary = salary;

this.name = name;

this.position = position;

this.ssn = ssn;

}

public String getSsn()

{

return ssn;

}

public String getName()

{

return name;

}

public String getPosition()

{

return position;

}

public int getSalary()

{

return salary;

}

public void setSsn(String ssn)

{

this.ssn = ssn;

}

public void setName(String name)

{

this.name = name;

}

public void setPosition(String position)

{

this.position = position;

}

public void setSalary(int salary)

{

this.salary = salary;

}

public void raise()

{

salary+=500;

}

public void raise(int amount)

{

salary+=amount;

}

public void raise(double percentage)

{

salary+=(int)((percentage*salary)/100);

}

// Print employee information

public void printE()

{

System.out.println("Ssn: " + ssn + " Name: " + name + " Position: " + position + " Salary: $" + salary + " ");

}

}

EmployeeDemo:

import java.util.Scanner;

public class EmployeeDemo

{

public static void main(String[] args)

{

Scanner obj = new Scanner(System.in);

Employee emp[] = new Employee[10];

int count = 0;

for (int i = 0; i < 10; i++)

{

String name, ssn, position;

int salary;

System.out.println(" Enter the information for employee "+(i+1)+".");

System.out.print("Ssn: ");

ssn = obj.nextLine();

System.out.print("Name: ");

name = obj.nextLine();

System.out.print("Position: ");

position = obj.nextLine();

System.out.print("Salary: $");

salary = Integer.parseInt(obj.nextLine());

Employee em = new Employee(ssn, name, position, salary);

emp[count++] = em;

}

//increment salary based on salary range

for (int i = 0; i < 10; i++)

{

if (emp[i].getSalary() < 1000)

{

emp[i].raise();

}

else if (emp[i].getSalary() < 2000)

{

emp[i].raise(300);

}

else

{

emp[i].raise(10.0);

}

}

//print the employee info

for (int i = 0; i < 10; i++)

{

emp[i].printE();

}

}

}

Explanation / Answer

If you have any doubts, please give me comment...

Employee.java

import java.util.Scanner;

public class Employee {

private String ssn;

private String name;

private String position;

private int salary;

public Employee(String ssn, String name, String position, int salary) {

this.salary = salary;

this.name = name;

this.position = position;

this.ssn = ssn;

}

public String getSsn() {

return ssn;

}

public String getName() {

return name;

}

public String getPosition() {

return position;

}

public int getSalary()

{

return salary;

}

public void setSsn(String ssn)

{

this.ssn = ssn;

}

public void setName(String name)

{

this.name = name;

}

public void setPosition(String position)

{

this.position = position;

}

public void setSalary(int salary)

{

this.salary = salary;

}

public void raise()

{

salary += 500;

}

public void raise(int amount)

{

salary += amount;

}

public void raise(double percentage)

{

salary += (int) ((percentage * salary) / 100);

}

// Print employee information

public String toString()

{

return "Ssn: " + ssn + " Name: " + name + " Position: " + position + " Salary: $" + salary;

}

public boolean equals(Employee e){

if(e.getSalary() == getSalary())

return true;

return false;

}

}

EmployeeDemo.java

import java.util.Scanner;

public class EmployeeDemo {

public static void main(String[] args) {

Scanner obj = new Scanner(System.in);

Employee emp[] = new Employee[10];

int count = 0;

for (int i = 0; i < 10; i++) {

String name, ssn, position;

int salary;

System.out.println(" Enter the information for employee " + (i + 1) + ".");

System.out.print("Ssn: ");

ssn = obj.nextLine();

System.out.print("Name: ");

name = obj.nextLine();

System.out.print("Position: ");

position = obj.nextLine();

System.out.print("Salary: $");

salary = Integer.parseInt(obj.nextLine());

Employee em = new Employee(ssn, name, position, salary);

emp[count++] = em;

}

// increment salary based on salary range

for (int i = 0; i < 10; i++) {

if (emp[i].getSalary() < 1000) {

emp[i].raise();

} else if (emp[i].getSalary() < 2000) {

emp[i].raise(300);

} else {

emp[i].raise(10.0);

}

}

// print the employee info

for (int i = 0; i < 10; i++) {

System.out.println(emp[i].toString());

}

System.out.println("Pairs of employees have same salary:");

for(int i=0; i<10; i++){

for(int j=i+1; j<10; j++){

if(emp[i].equals(emp[j]))

System.out.println(emp[i].getSsn()+" "+emp[j].getSsn());

}

}

}

}