// gpa.java
// basic kind of accurate gpa calculator with rudimentary introduction/welcome
import java.util.Scanner; // program uses scanner
import java.math.*; // math stuff
public class gpa
{
//static double A; forget about this at the moment i dont know how to really use it yet
//static double A_minus;
//static double B_plus;
//static double B;
//static double B_minus;
//static double C_plus;
//static double C;
//static double C_minus;
//static double D;
//static double F;
// main method begins program execution
public static void main( String[] args )
{
// create Scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
// create a GradeBook object and assign it to myGradeBook
gpacn myGradeBook = new gpacn();
// display initial value of courseName
System.out.printf ( "Initial course name is: %s\n\n",
myGradeBook.getCourseName () );
// prompt for and input course name
System.out.println ( "Enter semester number (1,2,3,4,5, etc) :" );
String theName = input.nextLine(); // read a line of text
myGradeBook.setCourseName ( theName ); // set the course name
System.out.println(); // outputs a blank line
// display welcome message after specifying course name
myGradeBook.displayMessage();
// end main
float c_num; // total number of courses calculated
float c1g; // course1 grade
float c2g; // course2 grade
float c3g; // course3 grade
float c4g; // course4 grade
float c5g; // course5 grade
float cum_prog; // program gpa 10scale
float cum_gpa; // total semester gpa 4 scale
float necvar; // equals 4
necvar = 4;
System.out.print ("Enter the total number of courses for the semester: "); // prompt for input
c_num = input.nextInt();
if (c_num == 3) {
System.out.print ("Enter the number value that corresponds to the letter grade received for course one\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c1g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course two\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c2g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course three\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c3g = input.nextInt();
cum_prog = ((c1g + c2g +c3g) / ( c_num )); // calculate semester GPA for 3 courses
cum_gpa = ( necvar - (cum_prog / necvar) );
System.out.println ("Your GPA for this semester is " + cum_gpa);
} else if (c_num == 4) {
System.out.print ("Enter the number value that corresponds to the letter grade received for course one\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c1g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course two\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c2g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course three\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c3g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course three\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c4g = input.nextInt();
cum_prog = ((c1g + c2g + c3g + c4g) / ( c_num)); // calculate semester gpa for 4 courses
cum_gpa = ( necvar - (cum_prog / necvar) );
System.out.println ("Your GPA for this semester is " + cum_gpa);
} else if (c_num == 5) {
System.out.print ("Enter the number value that corresponds to the letter grade received for course one\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c1g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course two\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c2g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course three\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c3g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course three\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c4g = input.nextInt();
System.out.print ("Enter the number value that corresponds to the letter grade received for course three\n (1=A, 2=A-, 3=B+, 4=B, 5=B-,6=C+, 7=C, 8=C-, 9=D, 10=F: "); // prompt for input
c5g = input.nextInt();
cum_prog = ((c1g + c2g + c3g + c4g + c5g) / ( c_num)); // calculate semester gpa for 5 courses
cum_gpa = ( necvar - (cum_prog / necvar) );
System.out.println ("Your GPA for this semester is " + cum_gpa);
} // end main
}// end class gpa.java
}