import java.util.*;
import java.util.Scanner;
public class arrays
{
public static void main(String[] args) {
int[] grades = new int[20];
int max = 100;
int min = 60;
int high = 59;
int low = 101;
int randNum;
int avg = 0;
int average;
for(int i = 0; i <grades.length; i++){
randNum = (int)(Math.random() * ((max - min) + 1)) + min;
grades[i] = randNum;
System.out.print(grades[i] + " ");
}
for(int i = 0; i <grades.length; i++){
if(grades[i] > high)
high = grades[i];
if(grades[i] < low)
low = grades[i];
avg += grades[i];
}
average = avg/20;
System.out.println("");
System.out.println("Average grade: " + average);
System.out.println("Highest grade: " + high);
System.out.println("Lowest grade: " + low);
}
}
Be the first to 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.