Write a program to calculate a students GPA.
What I cant figure is how to calculate ( Total= credit * grade + credit * grade...etc)

or

If you run this program, you will see my calculation off by a lot.

import java.util.Scanner;
import java.io.*;

public class GPA
{

private int total;
private int credits;
private double gpa;
private int creditCounter2;

public static void main(String[] args)throws IOException
{
Scanner key = new Scanner(System.in);
System.out.println("How many classes will you enter?");
int amount = key.nextInt();

key.nextLine();

int number;
int total = 0;
int credits = 0;
double gpa = 0;
int creditCounter2 = 0;
String className;

for
(number = 1;number <=amount;number++)
{

System.out.println("Enter Class Name and Course Number:");
className = key.nextLine();

System.out.println("How many Credits is this class?");
credits = key.nextInt();
creditCounter2++;

key.nextLine();

System.out.println(className  + "\t"+ letter + "\t" + credits);

gpa  = total/(number*letter);

if((letter =='Z') || (letter  == 'z'))
{
System.out.println("Try Again");
}
else if((letter == 'A') || (letter == 'a'))
{
gpa = (gpa + 4.0) / number;
}
else if((letter == 'B') || (letter == 'b'))
{
gpa = (gpa + 3.0) / number;
}
else if((letter == 'C') || (letter == 'c'))
{
gpa = (gpa + 2.0) / number;
}
else if((letter == 'D') || (letter == 'd'))
{
gpa = (gpa + 1.0) / number;
}
else if((letter == 'F') || (letter == 'f'))
{
gpa = (gpa + 0.0) / number;
}

}

System.out.println("Total grade points: " + total);
System.out.println("Your GPA is a: " +gpa);

}

}

Here is a small portion from a GPA calculator that I wrote. I believe it should be able to answer your question about performing the actual calculations.

hours = scan.nextDouble();