Question: In Java we were supsoed to create a program where it read a list of grades from a text file and then calculate a GPA
In Java we were supsoed to create a program where it read a list of grades from a text file and then calculate a GPA but im running into a error in the code below where im getting a null pointer exeption. im not sure here im going wrong and any help would be great.
package program1; import algs31.BinarySearchST; import stdlib.*;
public class ComputeGPA { public static void main(String[] args) { BinarySearchST
double totalGradePoints = 0.0; int numGrades = 0;
StdIn.fromFile("data/a1grades.rtf");
while (!StdIn.isEmpty()) { String grade = StdIn.readString(); totalGradePoints += gradePointsST.get(grade); // running into errors here on this line. numGrades++; }
System.out.println("GPA = " + totalGradePoints / numGrades); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
