0

Hey guys,

I think I have this mostly figured out but i'm still getting some errors, I'm not sure if it's a syntax thing or if I called out a variable wrong.

For some reason eclipse is saying that my variable [B]average[/B] "may not have locally been declared" which doesn't make sense to me, because it is, or so I think. If you could take a look and give me an idea of what is cause this I would really appreciate it!

```
import java.util.Random;
public class lab11a_killackey {
public static void main(String args[])
{
Random randomNumbers = new Random();
int a[]= new int [ 1000 ];
a [1000] = 1 + randomNumbers.nextInt( 51 );
int big = -1;
int small = 52;
int n;
for (int i=0; i<1000; i++)
{
if (a[i]> big)
big = a[i];
}
for (int i=0; i<1000; i++)
{
if (a[i] < small )
small = a[i];
}
int average;
for (int i= 0; i<1000; i++)
[B]average[/B] += (a[i])/1000;
int ans;
ans= countItems(a, [B]average[/B]);
int ansb;
ansb = countItemsb(a, [B]average[/B]);
System.out.printf("The largest of the 1000 integers is: %d", big);
System.out.printf("The smallest of the 1000 integers is: %d", small);
System.out.printf("The[B] average[/B] of the 1000 integers is: %d", average);
System.out.printf("The number of integers below average is: %d", ansb);
System.out.printf("The number of integers above average is: %d",ans);
}
public static int countItems( int a [], int average)
{
int cnt = 0;
for (int i= 0; i<1000; i++)
if (a[i] > average)
cnt ++;
return cnt;
}
public static int countItemsb(int a[], int average)
{
int cntb = 0;
for (int i=0; i<1000; i++)
if(a[i] < average)
cntb++;
return cntb;
}
}
```

*Edited
by mike_2000_17*: Fixed formatting