CODE
ublic class CalculateGrade
{
public classType[][] Grades;
public int[] numClasses;
public CalculateGrade(){
Grades = new classType[4][8];
numClasses = new int[4];
}
public void edit(){
System.out.println("Which year is this? 0-freshman 1-sophomore 2-Junior 3 Senior");
int year = keyboard.readInt();
System.out.println("Enter how many classes you have");
numclasses[year]=keyboard.readInt();
String classname;
int grade;
int totalpoints;
for(int x=0; x<numclasses[year];x++)
{
System.out.println("Enter Your classes");
System.out.println("Enter the class name");
Grades[year][x]= new classType(classname,grade,totalpoints);
}
printMenu();
int choice = keyboard.readInt();
while(choice!=0)
{
dispatch(choice);
printMenu();
choice = keyboard.readInt();
}
}
public static void printMenu(){
System.out.println("What would you like to do? Press 1 to EDIT CLASSES, Press 2 to VIEW GPA/GRADES, PRESS 3 TO ENTER GRADES");
}
public static void dispatch(int choice)
{
ConsoleIO keyboard = new ConsoleIO();
int loc;
switch(choice)
{
case 0:
break;
case 1:
System.out.println("Edit your classes");
student.edit();
case 2:
System.out.println("Enter your grades");
student.editgrades();
case 3:
system.out.println("View your GPA");
student.viewgrades();
public void editgrade(){
System.out.println("Which grade would you like to enter grades for? 0-freshman 1-sophomore 2-Junior 3 Senior");
int year=keyboard.readInt();
System.outprintln("Which class would you like to enter grades for(enter classname)?");
int x=keyboard.readInt();
System.out.println("how many sets of grades would you like to enter");
int gradesets=keyboard.readInt();
int totalpoints=0;
int totalpointsavailable=0;
for(int numenters=0;numenters<=gradesets;numenters++)
{
System.outprintln("Please enter how many points the assignment was out of");
int pointsavailable=keyboard.readInt();
System.out.println("How many points did you get on the assignment");
pointsgotten=keyboard.readInt();
totalpoints+=pointsgotten;
totalpointsavailable+=pointsavailable;
//adds the grades that have been entered to the total points
}
Grades[year][period].updatepoints(totalpoinsavailable);
//stores the new totalpoints for that specific class chosen
printMenu();
int choice = keyboard.readInt();
while(choice!=0)
{
dispatch(choice);
printMenu();
choice = keyboard.readInt();
}
}
public static void printMenu(){
System.out.println("What would you like to do? Press 1 to EDIT CLASSES, Press 2 to VIEW GPA/GRADES, PRESS 3 TO ENTER GRADES");
}
public static void dispatch(int choice)
{
ConsoleIO keyboard = new ConsoleIO();
int loc;
switch(choice)
{
case 0:
break;
case 1:
System.out.println("Edit your classes");
student.edit();
case 2:
System.out.println("Enter your grades");
student.editgrades();
case 3:
system.out.println("View your GPA");
student.viewgrades();
public void viewgrades{
{
Grades[year][x]=(totalpoints/totalpointsavailable);
if(Grades[year][x]>=90.000)
{
int GPApoints=4;
int totalgpapoints+=GPApoints;
}
else(Grades[year][x]>=80.000)
GPApoints=3;
int totalgpapoints+>GPApoints;
else(Grades[year][x]>=70.000)
GPApoints=2;
int totalgpapoints+=GPApoints;
else(Grades[year][x]>=60.000)
GPApoints=1;
int totalgpapoints+=GPApoints;
else(Grades[year][x]>=0.000)
GPApoints=0;
int totalgpapoints+=GPApoints;
//from the division of totalpointsgotten/totalpointsavailable the percent is found to give gpa points which are added in the for loop to the totalGPA points
double GPA=(double)totalgpapoints/numclasses;
//this takes total gpa points and divides them by the numclasses which the user entered
Grades[year][period].updatepoints(totalgpapoints);
System.out.print("Your GPA is"+ GPA);
}
}
printMenu();
int choice = keyboard.readInt();
while(choice!=0)
{
dispatch(choice);
printMenu();
choice = keyboard.readInt();
}
public static void printMenu(){
System.out.println("What would you like to do? Press 1 to EDIT CLASSES, Press 2 to VIEW GPA/GRADES, PRESS 3 TO ENTER GRADES");
}
public static void dispatch(int choice)
{
ConsoleIO keyboard = new ConsoleIO();
int loc;
switch(choice)
{
case 0:
break;
case 1:
System.out.println("Edit your classes")
student.edit();
case 2:
System.out.println("Enter your grades")
student.editgrades();
case 3:
system.out.println("View your GPA")
student.viewgrades();
}
}
I need to calculate grades using useres input of assignment points
Example
55/59
then add it to total points out of a speiific classes grades that the user has chosen.
If the user chooes view grades, these points will be used to calculate GPA from grades.