package Project64; import java.util.*; public class LetterGrade { public static String getLetterGrade(double d){ double grade=d; String lettergrade="Grade"; if (grade >=96) lettergrade = "A+"; else if (grade >=92) lettergrade = "A"; else if (grade >=90) lettergrade = "A-"; else if (grade >= 86) lettergrade = "B+"; else if (grade>=82) lettergrade = "B"; else if (grade>=80) lettergrade = "B-"; else if (grade>=76) lettergrade = "C+"; else if (grade>=72) lettergrade = "C"; else if (grade>=70) lettergrade = "C-"; else if (grade>=66) lettergrade = "D+"; else if (grade>=62) lettergrade = "D"; else if (grade>=60) lettergrade = "D-"; else if (grade>=0) lettergrade = "F"; return lettergrade; } public static void main(String[] args) { //LetterGrade machine = new LetterGrade(); Scanner reader = new Scanner(System.in); boolean boo = true; double average=0, total=0; double min=100; double max=0; double count=0; while (boo==true){ System.out.print("Please enter a score: "); double input = reader.nextDouble(); if (input>=0){ total = total +input; count++; if (input > max) max = input; if (input < min) min = input; }else {
boo=false; } average = total / count; } String averagelet = LetterGrade.getLetterGrade(average); String maxlet=LetterGrade.getLetterGrade(max); String minlet= LetterGrade.getLetterGrade(min); System.out.printf("The average is: %.1f" ,average); System.out.println(" " + averagelet); System.out.printf("The top score is: %.1f" , max); System.out.println(" " + maxlet); System.out.printf("The lowest score is: %.1f" , min); System.out.println(" " + minlet); } }