/**
* Write a description of class ArraysProgram here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Random;
public class ArraysProgram
{
public static void main (String[] args) {
System.out.println(" ");
Random rand = new Random();
double[] grades = new double[20];
for (int i=1; i <= 20; i++) {
int n = rand.nextInt(41) + 60;
grades[i-1] = n;
}
double max = grades[0];
double min = grades[0];
double total = 0;
for (int in=0; in < grades.length; in++) {
//System.out.println(grades[in]);
if (grades[in] > max) {
max = grades[in];
}
if (grades[in] < min) {
min = grades[in];
}
total += grades[in];
}
double average = total/grades.length;
System.out.println("Max: " + max);
System.out.println("Min: " + min);
System.out.println("Average: " + average);
}
}
2 Responses
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.