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

Use java thanks SECTION A Programming Question- 5 marks Question 1 (5 marks) Alp

ID: 3906644 • Letter: U

Question

Use java thanks SECTION A Programming Question- 5 marks Question 1 (5 marks) Alpha college has requested you to write a simple program to manage their employee's All employees have an identification number, name and job title. Employees contribute 7% of their gross pay towards employee provident fund that is to be deducted from their gross pay. e and mplement the employee class. The class should have the appropriate accessors and the employee's pay. The class should override the mutators as well as a method to compute toString0 method to return the values of instances. Write an application to create an array of employees to store at least 5 employee r would need to get details for the employee record from the user. Print the re employees using an iteration technique to display each employee's detail as Ensure you have the output screenshot uploaded with the codes. ecords. You cords of the above well as the net pay

Explanation / Answer

import java.util.Scanner;

class Employee{

// DECLARING variables

int id;

String name, jobTitle;

int grossPay;

// constructor to initialize variables

Employee(int id, String name, String jobTitle, int grossPay){

this.id = id;

this.name = name;

this.jobTitle = jobTitle;

this.grossPay = grossPay;

}

// setters and getters

void setId(int id){

this.id = id;

}

int getId(){

return id;

}

void setName(String name){

this.name = name;

}

String getName(){

return name;

}

void setJobTitle(String jobTitle){

this.jobTitle = jobTitle;

}

String getJobTitle(){

return jobTitle;

}

void setGrossPay(int grossPay){

this.grossPay = grossPay;

}

int getGrossPay(){

return grossPay;

}

// method to get the pay

double getPay(){

return (0.93)*grossPay;

}

// overriding toString method

public String toString(){

return name+" | ID:"+id+" | Job Title:"+jobTitle+" | Pay:"+Math.round(getPay() * 100.0) / 100.0;

}

}

class Main {

public static void main(String[] args) {

// declaring variables

Employee[] ee = new Employee[5];

int id;

String name, jobTitle;

int grossPay;

Scanner sc = new Scanner(System.in);

// asking for user input of 5 employees

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

{

System.out.printf(" Enter ID of the employee #%d: ",i+1);

id = sc.nextInt();

System.out.printf("Enter name of the employee #%d: ",i+1);

name = sc.next();

System.out.printf("Enter job title of the employee #%d: ",i+1);

jobTitle = sc.next();

System.out.printf("Enter gross pay of the employee #%d: ",i+1);

grossPay = sc.nextInt();

ee[i] = new Employee(id, name, jobTitle, grossPay);

}

// printing output

System.out.println(" Following is the data of the employees ");

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

{

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

}

}

}

/*SAMPLE OUTPUT

Enter ID of the employee #1: 12

Enter name of the employee #1: John

Enter job title of the employee #1: Dev

Enter gross pay of the employee #1: 2340

Enter ID of the employee #2: 43

Enter name of the employee #2: Alicia

Enter job title of the employee #2: Dev

Enter gross pay of the employee #2: 8976

Enter ID of the employee #3: 13

Enter name of the employee #3: Hart

Enter job title of the employee #3: QA

Enter gross pay of the employee #3: 2341

Enter ID of the employee #4: 89

Enter name of the employee #4: Ellen

Enter job title of the employee #4: Manager

Enter gross pay of the employee #4: 23034

Enter ID of the employee #5: 87

Enter name of the employee #5: Oprah

Enter job title of the employee #5: Lead

Enter gross pay of the employee #5: 3212

Following is the data of the employees

John | ID:12 | Job Title:Dev | Pay:2176.2

Alicia | ID:43 | Job Title:Dev | Pay:8347.68

Hart | ID:13 | Job Title:QA | Pay:2177.13

Ellen | ID:89 | Job Title:Manager | Pay:21421.62

Oprah | ID:87 | Job Title:Lead | Pay:2987.16

*/

// Note: You can run it online using link : https://repl.it/@sindhuvegi/Employee-07-pay-name-title-gross-pay-and-ID-5-employees