Array help please
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
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.
Im so stuck on this can anyone please help??:(sweat):
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.
Very unrealistically yes the observer only sees one at a time, so if he sees two rhinos it needs to be inputted like
if that makes sense
What have you tried so far? Do you need to use an array? A map could be helpful in a situation like this.
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;
Scanner scanner = new Scanner(System.in);
Animal = 1;
Animal = 2;
Animal = 3;
Animal = 4;
Animal = 5;
Animal = 6;
Animal = 7;
Animal = 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?
Your scanner line simply creates the object, however; it doesn't actually use it. Your pseudocode should look something like this
This is a very basic representation. How are people supposed to know which type of animal goes in which array slot?
create array of size x
get input from user with scanner
fill slot of array
Ahh missed that part, They know what number goes with the animal. Lets assume the observer sees a rhino he knows to press 5