Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This program analyzes an array of grades.
- *
- * Michael Zhou
- * October 4th, 2019
- */
- import java.util.*;
- public class GradeArray {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int[] grades = new int[20];
- for(int i = 0; i < 20; i++) {
- int randomNum = (int) (Math.random() * ((100 - 60) + 1) + 60);
- grades[i] = randomNum;
- }
- int low = grades[0];
- double total = 0.0;
- for(int i = grades.length - 1; i >= 0; i--) {
- if(grades[i] < low) {
- low = grades[i];
- }
- total += grades[i];
- System.out.print(grades[i] + " ");
- }
- System.out.println("\nThe lowest grade is a " + low + ".");
- double avg = total/20.0;
- avg = (int)(100 * avg + 0.5) / 100.0;
- System.out.println("Total Average is: " + avg + ".");
- total -= low;
- avg = total/19;
- avg = (int)(100 * avg + 0.5) / 100.0;
- System.out.println("Without Low Average is: " + avg + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement