Question: 5 4 . 1 1 LAB: Extending Gradebook with Methods Using the letter to GPA program that you wrote in project two, this lab extends

54.11 LAB: Extending Gradebook with Methods
Using the letter to GPA program that you wrote in project two, this lab extends the previous lab on creating a gradebook using arrays. Similarly, the program asks how many classes the user has, and then takes the name of the class, the grade, and the number of credit hours for each class. The program prints out a table showing the GPA associated with each letter grade, the credits, the final weighted GPA, and total credit hours.
In this lab, you will write two methods in the main class. The first method is to convert a letter grade to a GPA value. The second method calculating the weighted GPA of all classes.
Learning Objective: How to create user-defined methods
Sample Outputs:
What i have so far: import java.util.Scanner; import java.util.Arrays; public class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); //TODO: assemble code and print output System.out.println("Please enter the number of classes you have: "); String numberString = input.nextLine(); int numClasses = Integer.parseInt(numberString); String classesTotal []= new String [numClasses]; int gradeTotal []= new int [numClasses]; int creditTotal []= new int [numClasses]; for(int i =0; i numClasses; i++){ System.out.println("Please enter class "+(i+1)+ "name: "); classesTotal[i]= input.nextLine(); System.out.println("Please enter class "+(i+1)+ "grade: "); gradeTotal[i]= input.nextLine(); System.out.println("Please enter class "+(i+1)+ "credit hours: "); String creditStr = input.nextLine(); creditTotal[i]= Integer.parseInt(creditStr); } System.out.println(classes } public static double GradeToGPA(String grade){//TODO: convert letter grade to numeric GPA value double gpa =0.0; if(grade.equals("A")){ gpa +=4.0; } else if(grade.equals("A-")){ gpa +=3.7; } else if(grade.equals("B+")){ gpa +=3.3; } else if(grade.equals("B")){ gpa +=3.0; } else if(grade.equals("B-")){ gpa +=2.7; } else if(grade.equals("C+")){ gpa +=2.3; } else if(grade.equals("C")){ gpa +=2.0; } else if(grade.equals("C-")){ gpa +=1.7; } else if(grade.equals("D+")){ gpa +=1.3; } else if(grade.equals("D")){ gpa +=1.0; } else if(grade.equals("E")){ gpa +=0.0; }//else{//System.out.println(grade +" is not a valid letter grade."); //} return gpa; } public static double getGPA(int numClasses, String[] grades, int[] credits){//TODO: calculate total GPA of student double totalGpa =0; for(int i =0; i ; i++){} return 0.0; }
Example 1:
5 4 . 1 1 LAB: Extending Gradebook with Methods

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!