Java Coding Help

CompNoob1

Baseband Member
Messages
49
Hi all

I was wondering if i could have some help on the following coding questions:
Tasks
Step 1 Creating MultiDimensional Arrays
a. Define a class called EmployeeData. In the main method define a multidimensional String array called employeeInfo, which stores the employee name and title.
b. Define a second array salary of type double, which stores the employee's salary. Traverse through the multidimensional array and display the employee name and title for those who earn a salary greater than 2000.

Sample code for initializing Multidimensional arrays:
String[][] employeeInfo = { {"Alex", "Joe", "James", "Tom"},
{"Manager", "Clerk", "Analyst", "Manager"} };

The problem I'm having is not able to figure out the coding to display the employee name and title who earns a salary greater than 2000.
P.S Andrew
 
Simple for loop here, assuming you have the double[] salary declared as a variable:

Code:
for(int x = 0; x<4;x++)
{
if salary[x] >=2000 then  System.out.Println(employeeInfo[x][x]);
}
 
thanks, i'll see if that works

Its comes up with ArrayIndexOutOfBounds runtime error and this is the line with the problem:

System.out.Println(employeeInfo[x][x]);
 
Back
Top Bottom