I'm new at learning java, and while following a tutorial from a book, I received this error Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0. I've tried researching from the net to find out more about the error, and I could not find the answer to this. To make things worse, the book's website no longer exists when I tried to go to their website.
The program is about calculating payments for 2 types of workers, Engineers and Technicians including Over time pays which is 1.5x the original salaries for the 2 different workers. Max working hours is 160 hours, and additional hours trigger the overtime rate.
Here's the code that I wrote:
class PayCalculator3 {
public static void main (String []args) {
final int maxNoOverTime = 160;
final double engineerHourlyPay = 30;
final double technicianHourlyPay = 25.5;
final double overTimeRate = 1.5;
int position = Integer.parseInt(args[0]);
int hoursWorked = Integer.parseInt(args[1]);
double salary;
salary =
(position == 0) ?
// employee is an Engineer
(hoursWorked <= maxNoOverTime) ?
// he did not work overtime
(hoursWorked * engineerHourlyPay)
:
// he worked overtime
((maxNoOverTime * engineerHourlyPay) + ((hoursWorked - maxNoOverTime) * (engineerHourlyPay * overTimeRate)))
: (position == 1) ?
// if employee is a Technician
(hoursWorked <= maxNoOverTime) ?
// he did not work Overtime
(hoursWorked * technicianHourlyPay)
:
// he worked overtime
((maxNoOverTime * technicianHourlyPay) + ((hoursWorked - maxNoOverTime) * (technicianHourlyPay * overTimeRate)))
:
//Employee Type unknown
-1;
String str = (salary != -1) ?
("This month's salary >> $" + salary)
:
("Who the heck are you?");
System.out.println(str);
}
}
Thank you very much in advance for all of your kind help :)

int position = Integer.parseInt(args[0]);if you didn't include any arguments on the command line.