posted by Adam Johnson .
I have written function called count where the count function take in one parameter and the parameter is a array of number. The problem I having is how do i return the numbers of negative elements, zeros, and values greater than zeros in the given array. I don't understand how the switch statement are suppose to implement it.
You are probably best to post the method so far. However, switch statements are shorthands for a group of if statements that all relate to the same quantity as:
if (x == 0) doSomething0();
else if (x == 1) doSomething1();
else if (x == 2) doSomething2();
else if (x == 3) doSomething3();
else if (x == 4) doSomething4();
So in your case you need to read the value from the array called numbers,
for (int counter=0, counter<numbers.length, n++)
// now use the if statements to count how many of each type there are in the array. For clarity you will need to declare three variables for number of negatives, positives and zeros. For example
then use the switch statements to count each of the tree types.