Payament
Free Photos
WordPress Themes

GradeArrays

import java.util.*; public class GradeArrays { public static void main(String[] args){ double[] grades = new double[20]; for (int i = 0; i<20; i++) { int randomNumber = (int) (Math.random( ) * (100 - 60) + 1) + 60; grades[i] = randomNumber; System.out.println("Grade is: " + grades[i]); }//end of first for loop double high = 0.0; double low = 100.0; double sum = 0.0; double average = 0.0; for(int i = 0; i < 20; i++){ double value = grades[i]; double value2 = grades[i]; if (value > high){ high = value; } if (value2 < low){ low = value2; } sum += grades[i]; average = sum / 20; }//end of 2nd for loop System.out.println("High: " + high); System.out.println("Low: " + low); System.out.println("Average: " + average); }//end of method }//end of class

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.