I have just started reading and I need help on any of my exercises.
I need an end user to input rain fall numbers for each user, then I need more rain than average rainfall, highest month and average rainfall of the lowest months and months.
I place the same number in the highest and lowest and I do not know why I am pulling my hair seriously. Any kind of help would be welcomed.
This is what I have done so far:
public square rain {/ ** * @ ultimate arguments * / public static zero main (string [] args) { Int [] Noah Group; Numgroup = new int [13]; Console Reader Console = New Console Reader (); Int supreme; Minimal info; Int index Int tempVal; Int Minnom; Int Min Indak; Int maxMonth; Int max index; System.out.println ("Welcome to Rain"); (Index = 1; index & lt; 13; index = index + 1) {System.out.println ("Please enter rain for the month" + index); TempVal = console.readInt (); While (tempVal & gt; 100} tempVal & lt; 0) {System.out.println ("The rating should be within 0 ... 100. Retry"); TempVal = console.readInt (); } Mail Group [index] = Tempele; } Low = number group [0]; (Min indices = 0; minindex
thanks,
Emily
See your code now
min = points Group [0];
Why? It seems that you are trying to do the minimum search to use this algorithm:
1.1 Suppose first number (which you think is
numgroup [0] < / Code>) minutes (as the name of
minimum
in your code)
1.2. Compare all other numbers with it, if any number is small, change the minimum (i.e.minimum
)
However, numgroup [0]
is not your first number! You started your first such loop
For
(index = 1; ...
Your first number is numgroup [1]
.
Next, your second loop starts
for
(minIndex = 0 ;
While the element on index 0 is never intended to be used by you (I think)
Next, learn this For if the number in the current walk is less than << Code> less
if (numgroup [0] & lt;
which always compares the element on the index 0 (which I think is) not intended by <0> min .
Comments
Post a Comment