hi
I am getting this an java.lang.array index out of bound exception: 2 error - I am wondering if this is where am getting it. look it over many times, and I know you all are tired of me but am learning.
I like the array but it can be annoying at time.
here is what I am talking about.
int[] arrgsalary = new int [2];
int lowest = arrgsalary[0];
int highest = arrgsalary[0];
System.out.println("please enter the gross salary for 2 employees");
for (i = 0; i<arrgsalary.length; i++) - I am wondering if this is the error here.
{
System.out.println((i+1) + ":");
arrgsalary[i]= userinput.nextInt();
if (arrgsalary[i] > highest)
{
highest = arrgsalary[i];
}
if(arrgsalary[i] < lowest)
{
lowest = arrgsalary[i];
System.out.println("the highest gross salary is:$ " + gsalary[i]);
System.out.println("the lowest gross salary is:$ " + gsalary[i]);
}
}
this is the output
how many employees do you wish to processed
2
please enter the regular employee number
MA213
please enter the regular employees first name
MaryAnn
please enter the regular employees last name
Adamson
what are the regular employee of hours worked
160
what is your qualification code
R
what is the regular worker fixed salary
7800
payslip
the employee number is MA213
the employee name is MaryAnnAdamson
the employee typecode is R
the employee deduction is: 33.0
the employee gross salary is: $ 7800.0
the employee net salary is: $ 33.0
what is the lecturer id number
MW222
what is the lecuturer first name
marva
what is the lecturer last name
wilkinson
what are the lecturer hours
160
what is the lecturer qualification code
L
payslip
the employee id number is MW222
the employee first name is marvawilkinson
the employee typecode is L
the employee deduction is 0.0
the employee gross salary is 0.0
the employee net salary is 0.0
please enter the gross salary for 2 employees
1:
8890
2:
9908
employee pay record
the number of regular workers process are 0.0
the number of lecturers processed are 0.0
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at luana_abcpayroll.Luana_ABCPayRoll.main(Luana_ABCPayRoll.java:207)
Java Result: 1