Click here to Skip to main content
14,332,414 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am taking a class in Java.
We have to make an dimensional array. Which I did.
But then we have to get the users input, find the matching input in the array and print the other party is that array. I do not know have to search the array and get the response.
Example:
String[][] states={
                        {"Alabama", "blue jay"},
                        {"Alaska", "mockingbird "},
};

So the user would type Alabama and then the program would say
State: Alabama
State Bird: blue jay

Could someone guide me please

What I have tried:

To many to list ... Trying to print normally by using the user input and more
Posted
Updated 4-Oct-18 13:27pm
v2
Rate this:
Please Sign up or sign in to vote.

Solution 2

Accessing a bidimensional array is trivial, in order to get row r and column c, use
states[r][c]

For instance
System.out.println(states[0][1]);
Outputs
blue jay
   
Comments
Maciej Los 4-Oct-18 16:20pm
   
5ed!
CPallini 4-Oct-18 16:25pm
   
Why thank you, sir!
Rate this:
Please Sign up or sign in to vote.

Solution 1

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think! Start by looking at your course notes: about input from the user, accessing elements of arrays, loops (you'll need two nested loops), and finally printing. I'm pretty sure all of this is covered recently!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

I am not asking you to do my homework. My professor is garbage, does not respond and i have looked over what he has given us. I am stuck...that is why i am here.
   
Comments
Mohibur Rashid 4-Oct-18 19:35pm
   
Not an answer. And yeah, it is easy to blame someone else. We have been there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100