write a payroll class that uses the following arrays as fields:
*employeeID.- an array of seven integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489
*hours.- An array of seven integers to hold the number of hours worked by each employee
*payRate.- An array of seven doubles to hold each employee's hourly pay rate
*wages.- An array of seven doubles to hold each employee's gross wages
Demonstrate the class in a complete program that displays each employee number and asks the user to enter that employee's hours and pay rate. It should then display each employee's identification number and gross wages.
This is what I've gotten so far
import java.util.Scanner;
public class PayrollTracker
{
private final int NUM_EMPLOYEES = 7;
private int[] employeeId = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489};
private int[] hours = new int[NUM_EMPLOYEES];
private double[] payRate = new double[NUM_EMPLOYEES];
private double[] wages = new double[NUM_EMPLOYEES];
public int getEmployeeId(int id)
{
return employeeId[id];
}
public double getWages(int id)
{
return wages[id];
}
public void setPayRate(int id, double pr)
{
payRate[id]=pr;
}
public void setHours(int id, int h)
{
hours[id]=h;
}
public void calcGrossWages()
{
for(int i = 0; i < NUM_EMPLOYEES; i++)
{
GrossWages[i] = hours[i]*payRate[i];
}
}
public static void main(String[] args)
{
int hrs;
double payr;
PayrollTracker pr = new PayrollTracker();
Scanner keyboard = new Scanner(System.in);
for(int i = 0; i < 7; i++)
{
System.out.println(pr.getEmployeeId(i));
System.out.println("Enter the amount of hours the employee worked ");
hrs = keyboard.nextInt();
pr.setHours(i, hrs);
System.out.println("Enter the pay rate at which the employee was paid ");
payr = keyboard.nextDouble();
pr.setPayRate(i, payr);
}
pr.calcGrossWage();
for(int i = 0; i < 7; i++)
{
System.out.println(pr.getEmployeeId(i) + " - " + pr.getWages(i));
}
}}
I'm getting a few error messages. Help anyone?
Moderator Edit: In the future, please remember -->
-Locke

New Topic/Question
Reply




MultiQuote




|