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 Solution

### Want to see the full answer?

Check out a sample Q&A here Students who’ve seen this question also like: Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education Not helpful? See similar books Database System Concepts
Introduction. 1PE 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 may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.