Hey all, I need some help on this program cause I'm stumped. Everytime I compile this program is gives me an error of either "cannot find symbol" or "int cannot be dereferenced". I'm still playing around with the code but I might have to put the other class in a separate program because I don't know what to do. Thanks in advance for your help I really appreciate it.
import java.util.Scanner;
class PayrollGet
{
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int payroll;
int hours;
double payRate;
double wages;
int employeeID;
for (int i = 0; i < 7; i++)
{
System.out.println("Employee #" + (i + 1));
do
{
System.out.print("\tHours: ");
hours = Integer.parseInt(kb.nextLine());
if(hours<0)
System.out.println("must be >=0");
}
while (hours < 0);
payroll.setHours(i, hours);
do
{
System.out.print("\tPay Rate: ");
payRate = Double.parseDouble(kb.nextLine());
}
while (payRate < 6.00);
payroll.setPayRate(i, payRate);
employeeID = payroll.getEmployeeID(i);
wages = payroll.calculateGrossPay(employeeID);
payroll.setWages(i, wages);
}
for (int i = 0; i < 7; i++)
{
System.out.print("Employee ID: " + payroll.getEmployeeID(i));
System.out.println("\tGross Wages: " + payroll.getWages(i));
}
}
}
public class Payroll {
private int[] employeeID = { 5658845, 4520125, 7895122, 877541, 8451277,
1302850, 7580489 };
private int[] hours = new int[7];
private double[] payRate = new double[7];
private double[] wages = new double[7];
public int getEmployeeID(int index)
{
return employeeID[index];
}
public int getHours(int index)
{
return hours[index];
}
public double getPayRate(int index)
{
return payRate[index];
}
public double getWages(int index)
{
return wages[index];
}
public void setEmployeeID(int index, int employeeID)
{
this.employeeID[index] = employeeID;
}
public void setHours(int index, int hours)
{
this.hours[index] = hours;
}
public void setPayRate(int index, double payRate)
{
this.payRate[index] = payRate;
}
public void setWages(int index, double wages)
{
this.wages[index] = wages;
}
public double calculateGrossPay(int theEmployeeID)
{
double grossPay = 0;
int employeeIndex = -1;
for (int i = 0; i < employeeID.length; i++)
{
if (employeeID[i] == theEmployeeID)
{
employeeIndex = i;
break;
}
}
if (employeeIndex != -1)
{
int h = hours[employeeIndex];
double r = payRate[employeeIndex];
grossPay = (h * r);
}
return grossPay;
}
}