Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 08-26-2008, 06:41 AM   #1
Baseband Member
 
CompNoob's Avatar
 
Join Date: Dec 2006
Posts: 49
Default Java Coding Help

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
__________________

CompNoob is offline   Reply With Quote
Old 08-26-2008, 12:48 PM   #2
Site Team
 
celegorm's Avatar
 
Join Date: Sep 2006
Posts: 10,713
Send a message via AIM to celegorm
Default Re: Java Coding Help

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]);
}
__________________

__________________
"as a fanboy i refuse to admit it and will pull countless things out of my butt to disprove it"

Team Thelegorm! Total Kills: 21 (i iz in uor profile, editsing your sigz)
celegorm is offline   Reply With Quote
Old 08-26-2008, 11:31 PM   #3
Baseband Member
 
CompNoob's Avatar
 
Join Date: Dec 2006
Posts: 49
Default Re: Java Coding Help

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]);
CompNoob is offline   Reply With Quote
Reply

« flash drive | Tips »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 11:37 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0