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

Java, You will need to write a class to hold and access the data fields in the t

ID: 3717909 • Letter: J

Question

Java, You will need to write a class to hold and access the data fields in the table below. You only need the instance variables, constructor and accessors for the four instance variables.
Suppose we have the following salary data for a set of individuals. in addition to the actual pay rate, and the number of hours worked per week, we also have info about the gender (male or female) of the employee. The following table indicates a sample collection of data we may be expected to receive.

Name | Male/Female | Hourly Rate | Hours Worked
Bob | M | 10.50 | 30
Jen | F | 12.00 | 30
Tom | M | 9.50 | 20
Pat | F | 15.65 | 40
Nick | M | 12.00 | 45
Mike | M | 15.00 | 35
Barb | F | 25.00 | 20
Katie | F | 14.00 | 30
John | M | 12.00 | 45
Mark | M | 7.75 | 40

Based on this data, you need to write a program to perform the following functions:

a. Compute the total weekly salary of All employees in the collection

b. Compute the total weekly salary of all Male employees in the collection

c. Compute the total weekly salary of all Female employees in the collection

d. Compute the total number of employees who are highly paid. A highly paid employee is defined as someone whose hourly rate is equal to or above a certain threshold. This threshold value is provided as a separate input to the program to allow for flexibility - for example, the threshold value this quarter could be $11 per hour, and next quarter it could be $12 and so on. Figure out how you will handle this.

Explanation / Answer

import java.io.*;
import java.util.*;
class EmployeeInformation

{

String _name;

char _gender;

float _hourlyRate;

int _hoursWorked;

public String GetName()
{
return _name;
}

public char GetGender()
{
return _gender;
}

public float HoureRate()
{
return _hourlyRate;
}

public int HoursWorked()
{
return _hoursWorked;
}

EmployeeInformation(String name, char gender, float hourlyRate, int hoursWorked)

{

_name = name;

_gender = gender;

_hourlyRate = hourlyRate;

_hoursWorked = hoursWorked;

}

}

public class Main

{

public static void main(String[] args) {

  

try {

  

//Reading the data from file

File file = new File("Employee.txt");

BufferedReader br = new BufferedReader(new FileReader(file));

  

//array of EmployeeInformation class to store data

EmployeeInformation[] empInfoArray = new EmployeeInformation[15];

  

//Reading data from line by line

String st;

int lineRead = 0;

while ((st = br.readLine()) != null)

{

// Spilt by |

String[] arr = st.split("\|");

  

if(lineRead > 0)

{

String name = arr[0].trim();

char gender = arr[1].trim().charAt(0);

float hourlyRate = Float.valueOf(arr[2].trim());

int hoursWorked = Integer.parseInt(arr[3].trim());

EmployeeInformation empInfoInstance = new EmployeeInformation(name,gender,hourlyRate,hoursWorked);

empInfoArray[lineRead-1] = empInfoInstance;

}

lineRead++;
// System.out.println(st);

}

  

//Solution a

//weekly salary for all employee

System.out.println("salary of all the employees");
for(int j = 0; j<lineRead-1; j++)
{
System.out.println("salary " + empInfoArray[j].HoursWorked()*empInfoArray[j].HoureRate());
}

//Solution b

//weekly salary for all Male employee

System.out.println("salary of all Male employees");
for(int j = 0; j<lineRead-1; j++)
{
if(empInfoArray[j].GetGender() != 'F')
System.out.println("salary " + empInfoArray[j].HoursWorked()*empInfoArray[j].HoureRate());
}  

//Solution c

//weekly salary for all Female employee

System.out.println("salary of all Female employees");
for(int j = 0; j<lineRead-1; j++)
{
if(empInfoArray[j].GetGender() != 'M')
System.out.println("salary " + empInfoArray[j].HoursWorked()*empInfoArray[j].HoureRate());
}

//Solution d

//salary above threshold value

Scanner sc = new Scanner(System.in);

System.out.println("Enter a threshold value ");
double value = sc.nextDouble();
System.out.println("salary above threshold value ");
for(int j = 0; j<lineRead-1; j++)
{
if(empInfoArray[j].HoureRate() > value)
System.out.println("salary " + empInfoArray[j].HoursWorked()*empInfoArray[j].HoureRate());
}

} catch(Exception e) {
System.out.println(e);
}

}

}

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