• 08-06-2011, 09:26 AM
mike2452
Hi there
I have a scenario where a wildlife observer is looking for animals in the wild. The observer must enter a number 1-8 depending on the animal he sees. which could look like this
1
4
3
3
1
8
4
2
3
and so on
I need to make an array with 7 animals. hippo, cheetah, buffalo, monkey, zebra, tiger, snake and Rhino

I need to attach these animals to an array 1 - 8.
then I want to use the scanner tool so the user can enter the numbers in at random according to what animal he sees.
Also each animal in the array needs a counter so it can increment how many times the observer sees the particular animal. then if the user presses 0 a summary of data will come up.

• 08-06-2011, 09:34 AM
JosAH
Can an observer see different sorts of animals? e.g. can s/he see two hippos and three cheetahs? Or is only one sort of animal visible at a certain moment in time? Pleae specify.

kind regards,

Jos
• 08-06-2011, 09:40 AM
mike2452
Hi Jos
Very unrealistically yes the observer only sees one at a time, so if he sees two rhinos it needs to be inputted like
2
2
if that makes sense

thanks
• 08-06-2011, 09:44 AM
sunde887
What have you tried so far? Do you need to use an array? A map could be helpful in a situation like this.
• 08-06-2011, 09:49 AM
mike2452
Yeah Im have to use an array, (Not 2 dimensional)
Its meant to be straight forward but im really new to this. I have done it like this so far
vehicle = new int[7];
Scanner scanner = new Scanner(System.in);
Animal[0] = 1;
Animal[1] = 2;
Animal[2] = 3;
Animal[3] = 4;
Animal[4] = 5;
Animal[5] = 6;
Animal[6] = 7;
Animal[7] = 8;
However the scanner doesn't pick up the digits when i type them in. I also need to have a counter for each and that needs to increment each time a number is entered if that makes sense. Am i on the right track?
• 08-06-2011, 09:52 AM
sunde887
Your scanner line simply creates the object, however; it doesn't actually use it. Your pseudocode should look something like this

Code:

```create scanner create array of size x loop   get input from user with scanner   fill slot of array end loop```
This is a very basic representation. How are people supposed to know which type of animal goes in which array slot?
• 08-06-2011, 10:01 AM
mike2452
Ahh missed that part, They know what number goes with the animal. Lets assume the observer sees a rhino he knows to press 5