Skip to content

Instantly share code, notes, and snippets.

@feehe21
Created September 27, 2018 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feehe21/89d5274693004e4a102058c90aad0740 to your computer and use it in GitHub Desktop.
Save feehe21/89d5274693004e4a102058c90aad0740 to your computer and use it in GitHub Desktop.
import java.util.*;
/**
* Write a description of class strings here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class grades
{
public static void main(String args[]){
//initialize variables
int[] grades = new int[20];
int min = 60;
int max = 100;
int low = 100;
double sum = 0.0;
double highSum = 0.0;
//create each grade, store a sum and the low
for(int i = 0; i<20; i++){
grades[i] = (int)(Math.random() * ((max-min) + 1)) + min;
sum += grades[i];
if(grades[i]<low){//check for low
low = grades[i];
}
}
//create averages
highSum = sum-low;
double average = (int)(100*(sum/grades.length))/100.0;
double highAverage = (int)(100*(highSum/grades.length))/100.0;
//display results
System.out.println(average + " = average");
System.out.println(highAverage + " = average without lowest grade");
System.out.println(low + " = low");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment