Created
June 5, 2018 20:39
-
-
Save AwlsomeAlex/dc3529ed36f5b7237ba23c4b15b6e874 to your computer and use it in GitHub Desktop.
Finds the Weighted Average GPA for Classes (Specific School Standard)
This file contains hidden or 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.Scanner; | |
public class grader { | |
static Scanner n = new Scanner(System.in); | |
static Scanner s = new Scanner(System.in); | |
static Scanner c = new Scanner(System.in); | |
public static void displayTitle() { | |
System.out.println(""); | |
System.out.println("================"); | |
System.out.println("| Great Grader |"); | |
System.out.println("================"); | |
System.out.println("Created by AwlsomeAlex [GPLv3]"); | |
System.out.println("Designed for AP Computer Science"); | |
System.out.println(""); | |
} | |
public static String getLetter() { | |
String letter; | |
System.out.print("Please type the Grade in this class: "); | |
double grade = n.nextDouble(); | |
if (grade >= 95.5) | |
letter = "A+"; | |
else if (grade >= 91.5) | |
letter = "A"; | |
else if (grade >= 87.5) | |
letter = "B+"; | |
else if (grade >= 83.5) | |
letter = "B"; | |
else if (grade >= 79.5) | |
letter = "C+"; | |
else if (grade >= 75.5) | |
letter = "C"; | |
else if (grade >= 71.5) | |
letter = "D+"; | |
else if (grade >= 67.5) | |
letter = "D"; | |
else | |
letter = "F"; | |
return letter; | |
} | |
public static String getWeight() { | |
System.out.print("Please type the weight of this class ('r' = CP, 'h' = Honors, 'a' = AP): "); | |
String weight = null; | |
char option = c.next().charAt(0); | |
if (option == 'r') | |
weight = "CP"; | |
else if (option == 'h') | |
weight = "Honors"; | |
else if (option == 'a') | |
weight = "AP"; | |
else { | |
System.out.println("ERROR: Invalid Weight! Exitting..."); | |
System.exit(1); | |
} | |
return weight; | |
} | |
public static double getGPA(String letter, String weight) { | |
double GPA = 0.0; | |
if (letter == "A+") | |
GPA = 4.5; | |
else if (letter == "A") | |
GPA = 4.0; | |
else if (letter == "B+") | |
GPA = 3.5; | |
else if (letter == "B") | |
GPA = 3.0; | |
else if (letter == "C+") | |
GPA = 2.5; | |
else if (letter == "C") | |
GPA = 2.0; | |
else if (letter == "D+") | |
GPA = 1.5; | |
else if (letter == "D") | |
GPA = 1.0; | |
else if (letter == "F") | |
GPA = 0.0; | |
if (weight == "Honors") | |
GPA = GPA + 1.0; | |
else if (weight == "AP") | |
GPA = GPA + 1.5; | |
System.out.println("==================================================="); | |
return GPA; | |
} | |
public static String getCourse() { | |
String course; | |
System.out.println(""); | |
System.out.println("==================================================="); | |
System.out.print("Please type the name of this class: "); | |
course = s.nextLine(); | |
return course; | |
} | |
public static double calcGPA(double gpa1, double gpa2, double gpa3, double gpa4, double gpa5, double gpa6, double gpa7, double gpa8) { | |
double finalGPA = (gpa1+gpa2+gpa3+gpa4+gpa5+gpa6+gpa7+gpa8)/8; | |
return finalGPA; | |
} | |
public static void main(String[] args) { | |
displayTitle(); | |
System.out.print("Please type your Name: "); | |
String name = s.nextLine(); | |
String c1N = getCourse(); | |
String c1L = getLetter(); | |
String c1W = getWeight(); | |
double c1GPA = getGPA(c1L, c1W); | |
String c2N = getCourse(); | |
String c2L = getLetter(); | |
String c2W = getWeight(); | |
double c2GPA = getGPA(c2L, c2W); | |
String c3N = getCourse(); | |
String c3L = getLetter(); | |
String c3W = getWeight(); | |
double c3GPA = getGPA(c3L, c3W); | |
String c4N = getCourse(); | |
String c4L = getLetter(); | |
String c4W = getWeight(); | |
double c4GPA = getGPA(c4L, c4W); | |
String c5N = getCourse(); | |
String c5L = getLetter(); | |
String c5W = getWeight(); | |
double c5GPA = getGPA(c5L, c5W); | |
String c6N = getCourse(); | |
String c6L = getLetter(); | |
String c6W = getWeight(); | |
double c6GPA = getGPA(c6L, c6W); | |
String c7N = getCourse(); | |
String c7L = getLetter(); | |
String c7W = getWeight(); | |
double c7GPA = getGPA(c7L, c7W); | |
String c8N = getCourse(); | |
String c8L = getLetter(); | |
String c8W = getWeight(); | |
double c8GPA = getGPA(c8L, c8W); | |
double finalGPA = calcGPA(c1GPA, c2GPA, c3GPA, c4GPA, c5GPA, c6GPA, c7GPA, c8GPA); | |
System.out.println(""); | |
displayTitle(); | |
System.out.println("============================================"); | |
System.out.println("| "+ name); | |
System.out.println("--------------------------------------------"); | |
System.out.println("| "+c1W+ " "+c1N+ ": "+c1L); | |
System.out.println("| "+c2W+ " "+c2N+ ": "+c2L); | |
System.out.println("| "+c3W+ " "+c3N+ ": "+c3L); | |
System.out.println("| "+c4W+ " "+c4N+ ": "+c4L); | |
System.out.println("| "+c5W+ " "+c5N+ ": "+c5L); | |
System.out.println("| "+c6W+ " "+c6N+ ": "+c6L); | |
System.out.println("| "+c7W+ " "+c7N+ ": "+c7L); | |
System.out.println("| "+c8W+ " "+c8N+ ": "+c8L); | |
System.out.println("--------------------------------------------"); | |
System.out.println("| Your Weighted GPA: "+ finalGPA); | |
System.out.println("============================================"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment