Skip to content

Instantly share code, notes, and snippets.

@itsJarrett
Created June 5, 2015 00:51
Show Gist options
  • Save itsJarrett/34d4cd9a0d0bd72f33ea to your computer and use it in GitHub Desktop.
Save itsJarrett/34d4cd9a0d0bd72f33ea to your computer and use it in GitHub Desktop.
GPA Calculator
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
getGPA();
}
public static void getGPA() {
Scanner s = new Scanner(System.in);
System.out.println("How many periods do you have?");
int periods = s.nextInt();
double combinded = 0;
for (int i = 1; i < periods + 1; i ++) {
System.out.println("What is your grade for period " + i + "?");
double gradepoint = s.nextDouble();
combinded += gradepoint;
}
double gpa = combinded / periods;
System.out.println("Your GPA is " + gpa);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment