WordPress Hosting
Free Photos
WordPress Themes

arrays

/** * Write a description of class grades here. *makes array and averages w/ high and low * @author (Rahul Khullar) * @version (10/9/2017) */ import java.util.*; public class grades { int[] grades = new int[20]; int randomNum; int high = 59; int low = 101; int avg; public grades() { for (int i = 0; i < 20; i++){ randomNum = (int)(Math.random() * ((100 - 60) + 1)) + 60; grades[i] = randomNum; System.out.print(grades[i] + " "); } for (int i = 0; i < 20; i++){ if (grades[i] < low){ low = grades[i]; } if (grades[i] > high){ high = grades[i]; } avg += grades[i]; } System.out.println(""); System.out.println("average: " + avg/20); System.out.println("high: " + high); System.out.println("low: " + 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.