I am creating a java program that will take 10 user input grades from 1-100 and display them as a letter grade, then calculate the percent of how many letter grades there are in total.
The last step is to figure out how to get each letter grade, lets say 5 F's, 2 B's, 2 C's, and 1 A, and get what total percentage of each letter grade there is out of ten so like 50% F's, 20% B's, etc. What do I do next? I assume I have to assign some doubles for the percent to display but my brain is fried right now.
Here is what I have so far:
import java.util.Scanner;
public class GradePercent {
public static void main(String[] args)
{
int g1, g2, g3, g4, g5, g6, g7, g8, g9, g10;
char grade;
System.out.println("Type 10 grades in whole numbers from 0-100");
System.out.println();
Scanner keyboard = new Scanner(System.in);
g1 = keyboard.nextInt( );
g2 = keyboard.nextInt( );
g3 = keyboard.nextInt( );
g4 = keyboard.nextInt( );
g5 = keyboard.nextInt( );
g6 = keyboard.nextInt( );
g7 = keyboard.nextInt( );
g8 = keyboard.nextInt( );
g9 = keyboard.nextInt( );
g10 = keyboard.nextInt( );
if (g1 >= 90) {
grade = 'A';
} else if (g1 >= 80) {
grade = 'B';
} else if (g1 >= 70) {
grade = 'C';
} else if (g1 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g2 >= 90) {
grade = 'A';
} else if (g2 >= 80) {
grade = 'B';
} else if (g2 >= 70) {
grade = 'C';
} else if (g2 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g3 >= 90) {
grade = 'A';
} else if (g3 >= 80) {
grade = 'B';
} else if (g3 >= 70) {
grade = 'C';
} else if (g3 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g4 >= 90) {
grade = 'A';
} else if (g4 >= 80) {
grade = 'B';
} else if (g4 >= 70) {
grade = 'C';
} else if (g4 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g5 >= 90) {
grade = 'A';
} else if (g5 >= 80) {
grade = 'B';
} else if (g5 >= 70) {
grade = 'C';
} else if (g5 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g6 >= 90) {
grade = 'A';
} else if (g6 >= 80) {
grade = 'B';
} else if (g6 >= 70) {
grade = 'C';
} else if (g6 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g7 >= 90) {
grade = 'A';
} else if (g7 >= 80) {
grade = 'B';
} else if (g7 >= 70) {
grade = 'C';
} else if (g7 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g8 >= 90) {
grade = 'A';
} else if (g8 >= 80) {
grade = 'B';
} else if (g8 >= 70) {
grade = 'C';
} else if (g8 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g9 >= 90) {
grade = 'A';
} else if (g9 >= 80) {
grade = 'B';
} else if (g9 >= 70) {
grade = 'C';
} else if (g9 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
if (g10 >= 90) {
grade = 'A';
} else if (g10 >= 80) {
grade = 'B';
} else if (g10 >= 70) {
grade = 'C';
} else if (g10 >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
}
}