I have been tasked with developing a code that calculates an employee(s) gross pay, with the condition that the hourly pay cannot fall below $8. Despite no visible errors during compilation, my code fails to execute.
public static void main(String[] args) {
Scanner key = new Scanner(System.in);
int numEmployees = key.nextInt();
int employeeName[] = new int[numEmployees];
int hoursWorked[] = new int[numEmployees];
int hourlyWage[] = new int[numEmployees];
int grossWages[] = new int[numEmployees];
System.out.println("Enter the number of employess whose gross wages"
+ " you wish to calculate:");
//user enter employee name
for(int i = 1; i < employeeName.length; i++)
{
System.out.println("Enter name of employee " + i+ ":");
employeeName[i]= key.nextInt();
i++;
}
//user enters number of hours
//System.out.println("How many hours did" + employeeName[i] + " work this week?");
for(int i = 0; i< numEmployees; i++)
{
System.out.print("How many hours did" + employeeName[i] + " work this week?");
hoursWorked[i] = key.nextInt();
//get the hourly pay rate
System.out.print("What is" + employeeName[i] + " hourly wage?");
//hourlyWage = key.nextInt();
grossWages[i] = hoursWorked[i] * hourlyWage[i];
}
//displays wages
System.out.println("The hours and pay rates you entered are:");
for(int i = 0; i < numEmployees; i++)
{
//hourlyWage = key.nextInt();
System.out.printf("The total wages for Employee #%d is $%.2f\n", employeeName[i], hourlyWage);
}
//System.out.print("");
//System.out.print("Name Hours Worked Hourly Pay Rate Gross Wages Earned");
//System.out.println(employeeName + " " + hoursWorked + " " + hourlyWage + " " + grossWages);
} }