Simplifying GPA calculator I'm only two weeks into learning Java and just finished creating my first program.  I have a feeling I've added unnecessary things, but not sure. I'd like someone to take a look at it and let me know if there are ways to simplify or approach the code.  Basically, I'm just trying to create a simple GPA calculator.

import java.util.Scanner;

class GpaCalculator {

    public static void main(String[] args) {
        Scanner myScanner = new Scanner(System.in);
        char c1;
        double gpa;
        double g1, g2, g3, g4, g5, g6;

        g1 = 0;
        g2 = 0;
        g3 = 0;
        g4 = 0;
        g5 = 0;
        g6 = 0;

        System.out.println("What is your grade for class 1?");
        c1 = myScanner.findWithinHorizon(".", 0).charAt(0);
        if (c1 == 'a' || c1 == 'A') {
            g1 = 4;
        }
        if (c1 == 'b' || c1 == 'B') {
            g1 = 3;
        }
        if (c1 == 'c' || c1 == 'C') {
            g1 = 2;
        }
        if (c1 == 'd' || c1 == 'D') {
            g1 = 1;
        }
        if (c1 == 'f' || c1 == 'F') {
            g1 = 0;
        }
        System.out.println("What is your grade for class 2?");
        c1 = myScanner.findWithinHorizon(".", 0).charAt(0);
        if (c1 == 'a' || c1 == 'A') {
            g2 = 4;
        }
        if (c1 == 'b' || c1 == 'B') {
            g2 = 3;
        }
        if (c1 == 'c' || c1 == 'C') {
            g2 = 2;
        }
        if (c1 == 'd' || c1 == 'D') {
            g2 = 1;
        }
        if (c1 == 'f' || c1 == 'F') {
            g2 = 0;
        }
        System.out.println("What is your grade for class 3?");
        c1 = myScanner.findWithinHorizon(".", 0).charAt(0);
        if (c1 == 'a' || c1 == 'A') {
            g3 = 4;
        }
        if (c1 == 'b' || c1 == 'B') {
            g3 = 3;
        }
        if (c1 == 'c' || c1 == 'C') {
            g3 = 2;
        }
        if (c1 == 'd' || c1 == 'D') {
            g3 = 1;
        }
        if (c1 == 'f' || c1 == 'F') {
            g3 = 0;
        }
        System.out.println("What is your grade for class 4?");
        c1 = myScanner.findWithinHorizon(".", 0).charAt(0);
        if (c1 == 'a' || c1 == 'A') {
            g4 = 4;
        }
        if (c1 == 'b' || c1 == 'B') {
            g4 = 3;
        }
        if (c1 == 'c' || c1 == 'C') {
            g4 = 2;
        }
        if (c1 == 'd' || c1 == 'D') {
            g4 = 1;
        }
        if (c1 == 'f' || c1 == 'F') {
            g4 = 0;
        }
        System.out.println("What is your grade for class 5?");
        c1 = myScanner.findWithinHorizon(".", 0).charAt(0);
        if (c1 == 'a' || c1 == 'A') {
            g5 = 4;
        }
        if (c1 == 'b' || c1 == 'B') {
            g5 = 3;
        }
        if (c1 == 'c' || c1 == 'C') {
            g5 = 2;
        }
        if (c1 == 'd' || c1 == 'D') {
            g5 = 1;
        }
        if (c1 == 'f' || c1 == 'F') {
            g5 = 0;
        }
        System.out.println("What is your grade for class 6?");
        c1 = myScanner.findWithinHorizon(".", 0).charAt(0);
        if (c1 == 'a' || c1 == 'A') {
            g6 = 4;
        }
        if (c1 == 'b' || c1 == 'B') {
            g6 = 3;
        }
        if (c1 == 'c' || c1 == 'C') {
            g6 = 2;
        }
        if (c1 == 'd' || c1 == 'D') {
            g6 = 1;
        }
        if (c1 == 'f' || c1 == 'F') {
            g6 = 0;
        }

        gpa = (g1 + g2 + g3 + g4 + g5 + g6) / 6;

        System.out.println("Your GPA is " + gpa + ". ");

        if (gpa &gt; 3.00) {
            System.out.println("Gret job, you're on your way to success.");
        } else if (gpa &gt; 2.00) {
            System.out.println("You did OK, but better than average.");
        } else {
            System.out.println("You didn't do too well. You should look into getting a tutor.");
        }
    }
}
First off, both Grade and Class (GradedClass to avoid confusion with java.lang.Class) make sense as enums.

enum Grade {
    A(4),B(3),C(2),D(1),F(0);

    private final int value;

    Grade(int value) {
        this.value = value;
    }

    int getValue() {
        return value;
    }
}

enum GradedClass {
    ONE, TWO, THREE, FOUR, FIVE, SIX;

    @Override
    public String toString() {
        return "class " + (ordinal() + 1);
    }
}


This will allow a much simpler calculation loop :

    public double calculateGpa() {
        return calculateTotal() / GradedClass.values().length;
    }

    private double calculateTotal() {
        double total = 0d;
        for (GradedClass gradedClass : GradedClass.values()) {
            Grade grade = userInterface.askGradeFor(gradedClass);
            total += grade.getValue();
        }
        return total;
    }


Note that I've hidden away the scanner behind a UserInterface interface, in order to separate calculation from UI code.

It's implemented by the ConsoleUI class :

class ConsoleUI implements UserInterface {
    Scanner myScanner = new Scanner(System.in);

    @Override
    public Grade askGradeFor(GradedClass gradedClass) {
        System.out.println(MessageFormat.format("What is your grade for {0}?", gradedClass));
        String input = myScanner.findWithinHorizon(".", 0);
        return Grade.valueOf(input.toUpperCase());
    }

    @Override
    public void presentGpa(double gpa) {
        if (gpa &gt; 3d) {
            System.out.println("Great job, you're on your way to success.");
        } else if (gpa &gt; 2d) {
            System.out.println("You did OK, but better than average.");
        } else {
            System.out.println("You didn't do too well. You should look into getting a tutor.");
        }
    }

}


The Main class simply ties everything together :

public class Main {

    public static void main(String[] args) {
        UserInterface ui = new ConsoleUI();
        GpaCalculator gpaCalculator = new GpaCalculator(ui);

        double gpa = gpaCalculator.calculateGpa();
        ui.presentGpa(gpa);
    }

}