Created
September 27, 2018 01:32
-
-
Save feehe21/89d5274693004e4a102058c90aad0740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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