import javax.swing.JOptionPane;
public class proj22
{
public static void main(String args[]) {
PrintExplanation();
name=name();
semesterValue=semesterValue();
courseName=courseName();
courseGrade = courseGrade();
GetValidNumberInput(courseName, credits, GPA);
GPA=CalculateGPA(credits, gradeNumber);
}
private static String name() {
// TODO Auto-generated method stub
return null;
}
private static String courseName() {
// TODO Auto-generated method stub
return null;
}
private static String courseGrade() {
// TODO Auto-generated method stub
return null;
}
private static String semesterValue() {
// TODO Auto-generated method stub
return null;
}
int lowerNum=1;
int upperNum=4;
static int gradeNumber,credits, GPA, semester;
static String name, creditsValue, semesterValue, courseName, courseGrade, prompt_user;
int totalCredits = 0;
int totalQualityPoints= 0;
//This explains what the program does and shows it to the person who is running it.
public static void PrintExplanation(){
JOptionPane.showMessageDialog(null, "This allows you to calculate your GPA for the semster you are/were in by entering the number/letter of your grades).");
}
public static void GetValidNumberInput(String promptStr, int lowerNum, int upperNum){
String name;
name= JOptionPane.showInputDialog("Hello, What is your name?");
System.out.println( "showInputDialog: " + name);
String semesterValue;
semesterValue = JOptionPane.showInputDialog("What semester are you in?");
System.out.println( "showInputDialog: " + semesterValue);
do {
String courseName;
courseName = JOptionPane.showInputDialog("What is the course name? \n or type 'end' if no courses left");
if(courseName.equals("end")) break;
System.out.println( "showInputDialog: " + courseName);
String courseGrade;
courseGrade= JOptionPane.showInputDialog("What did you make in this class?");
System.out.println( "showInputDialog: " + courseGrade);
String creditsValue;
creditsValue = JOptionPane.showInputDialog("How many hours was this class?");
if(credits < lowerNum || credits > upperNum){
JOptionPane.showMessageDialog(null,"That is not a valid number.");
} else {
credits += Integer.parseInt(creditsValue);
}
}while(!courseName.equals("end"));
}
public static void GenerateGPAReport ( int totalCredits, int totalQualityPoints){
//This shows what the GPA is
JOptionPane.showMessageDialog(null,"Grading Period:"+semester+ "\n Total Credits Taken :"+totalCredits+ "\n Total Quality Points:"+totalQualityPoints+"\n GPA:"+GPA);
}
public static int CalculateGPA (int totalCredits, int totalQualityPoints){
//Calculates the GPA
totalQualityPoints = credits * gradeNumber;
GPA = totalQualityPoints / totalCredits;
return GPA;
}
public static int ConvertGradeToPoints(String grade){
//This converts the grades inputed to a number (i.e. A = 4, B=3, C=2, ect)
;
if (grade.equalsIgnoreCase("A")){ gradeNumber = 4;
}
else
if
(grade.equalsIgnoreCase("B")){
gradeNumber = 3;
}
else
if
(grade.equalsIgnoreCase("C")) { gradeNumber = 2;
}
else
if
(grade.equalsIgnoreCase("D")){
gradeNumber = 1;
}
else
{
gradeNumber = 0;
}
return
gradeNumber;
}
}