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);

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
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 Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 4 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education