# Im trying to write code for java where the random array that I have genreated are used and then list the int above and below the average... here is what I have but I dont think its correct.    import java.util.Random; import java.util.Scanner;     public class Troubleshooting  { //Data Members public static final int N = 100;  public static final int SEED = -1; public static int sum; public static int min; public static int max; public static int avg; public static int greater; public static int smaller;     //Main Function public static void main(String[] args) {   sum = 0; int ary[] = new int [N];   Random rndGen = new Random(SEED);    //Populate  for(int i = 0; i < N; i++) { ary[i] = rndGen.nextInt(101); }   //Calculate Sum of Array for(int i = 0; i < N; i++) { sum += ary[i]; }   //Calculate Average of Array double avg = (double)sum/ (double)N;   //Minimum number in Array for(int i = 0; i < N; i++) { if(min > ary[i]) { min = ary[i]; }   }     //Max Number In Array int index = 0; for(int i = 0; i < N; i++) { //if(max = ary) { max = ary[i]; index = i; }   }     for (int i = 0; i < N; i++)           if (greater > avg)              greater = ary[i];   for (int i = 0; i < N; i++)           if (smaller < avg)              smaller = ary[i];   System.out.println("The Sum of the Array: "+sum); System.out.println("The Average is: " +avg); System.out.println("The Max Array is: " +max); System.out.println("The Min Array is: " +min); System.out.println("The bellow Average: " +smaller); System.out.println("The above Average: " +greater);

Question

Im trying to write code for java where the random array that I have genreated are used and then list the int above and below the average... here is what I have but I dont think its correct.

import java.util.Random;

import java.util.Scanner;

public class Troubleshooting

{

//Data Members

public static final int N = 100;

public static final int SEED = -1;

public static int sum;

public static int min;

public static int max;

public static int avg;

public static int greater;

public static int smaller;

//Main Function

public static void main(String[] args)

{

sum = 0;

int ary[] = new int [N];

Random rndGen = new Random(SEED);

//Populate

for(int i = 0; i < N; i++)

{

ary[i] = rndGen.nextInt(101);

}

//Calculate Sum of Array

for(int i = 0; i < N; i++)

{

sum += ary[i];

}

//Calculate Average of Array

double avg = (double)sum/ (double)N;

//Minimum number in Array

for(int i = 0; i < N; i++)

{

if(min > ary[i])

{

min = ary[i];

}

}

//Max Number In Array

int index = 0;

for(int i = 0; i < N; i++)

{

//if(max = ary)

{

max = ary[i];

index = i;

}

}

for (int i = 0; i < N; i++)

if (greater > avg)

greater = ary[i];

for (int i = 0; i < N; i++)

if (smaller < avg)

smaller = ary[i];

System.out.println("The Sum of the Array: "+sum);

System.out.println("The Average is: " +avg);

System.out.println("The Max Array is: " +max);

System.out.println("The Min Array is: " +min);

System.out.println("The bellow Average: " +smaller);

System.out.println("The above Average: " +greater);

## Expert Answer

### Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.
Tagged in © 2021 bartleby. All Rights Reserved.