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[0]) { 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[0])

{

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 the step-by-step answer?

Check out a sample Q&A here.

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.

Related Computer Science Q&A

Find answers to questions asked by student like you

Q: Consider the window size is 10, bandwidth is 1500 bps, transmission delay is 2 ms atpropagation dela...

A: Given information:

Q: Draw a decision tree and find the number of key comparisons in the worst and average cases for the t...

A: Decision tree (enhanced bubble sort):

Q: Python 3.7.4 Given four files named asiasales2009.txt, europesales2009.txt, africasales2009.txt, and...

A: Statements for creating objects:#for first file asiasales2009.txt for writingasia = open("asiasales2...

Q: Question 4: What does the following code output? vector icecream ( 10, "Vanilla" ); icecream.insert...

A: The complete source code for the given question is given below along with the output.Note: If the he...

Q: Hi, I am required to: Create an array of 100 integers using a random generator. ( 1 for loop) Provi...

A: The given java program will follow the following rubrics:Importing essential header files.Creating a...

Q: Use the Design Recipe to write a function weighted_total(number_list,weights) that consumes a list o...

A: The given list of numbers is [1, 2, 3].The given weights are [0.1, 0.5, 0.4].weighted_total(number_l...

Q: WAHT IS A BYZANTINE GENERALS PROBLEM OF DIGITAL CASH TRANSACTIONS?

A: The Bitcoin protocol provides a means for digital currency transactions, so that everyone can decide...

Q: Please put into SOP formxz + (xy + ~z)

A: A Boolean expression is said to be in the Canonical form either it has purely min-terms or max-terms...

Q: Write a simplified expression for the Boolean function defined by the following Kmap.

A: Identify only 1’s in the kmap group.Find the largest group of 1’s.In three varible a group can have ...