Click here to Skip to main content
15,882,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
Java
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

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.
 
Share this answer
 
Comments
Mohibur Rashid 4-Oct-18 19:35pm    
Not an answer. And yeah, it is easy to blame someone else. We have been there.
Accessing a bidimensional array is trivial, in order to get row r and column c, use
Java
states[r][c]

For instance
Java
System.out.println(states[0][1]);
Outputs
blue jay
 
Share this answer
 
Comments
Maciej Los 4-Oct-18 16:20pm    
5ed!
CPallini 4-Oct-18 16:25pm    
Why thank you, sir!
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!
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900