Code: Select all
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gpa.calculator;
import java.util.*;
public class GPA {
private static double[] grades = new double[32];
private static double average;
private static double fourPoint;
private static double totalGrade;
private static int counter;
private static double fourpointAverage;
public static double Calc(double grade){
double totalGrade =+ grade;
return totalGrade;
}
public static double findAverage(double totalGrade){
double average = totalGrade/counter;
return average;
}
public static double fourpointScale(double grade){
double fourPoint = 0;
if(grade >= 90){
fourPoint =+ 4.0;
}else if(grade >= 80){
fourPoint =+ 3.0;
}else if(grade >= 70){
fourPoint =+ 2.0;
}else if(grade >= 60){
fourPoint =+ 1.0;
}
return fourPoint;
}
public static double fourpointAverage(double fourPoint){
double fourpointAverage = fourPoint / counter;
return fourpointAverage;
}
public static void main(String[] args){
Scanner input = new Scanner(System.in);
for(int i=0;i<=31;i++){
System.out.println("Enter Grade:");
grades[i] = input.nextDouble();
}
for(int i=0;i<=31;i++){
if(grades[i] != 0){
double four = fourpointScale(grades[i]);
double overall = Calc(grades[i]);
counter =+ 1;
}
}
findAverage(totalGrade);
fourpointAverage(fourPoint);
System.out.println("Your GPA Is:" + fourpointAverage + " And " + average);
}
}
Help on the problem and general things I missed/should of done to make it easier.
P.S. if this was for real, I would go through and allow the user an "exit" kind of thing to not have to input 32 classes, or input more if they wanted.