Answered step by step
Verified Expert Solution
Question
1 Approved Answer
getGPA() needs to continues to return correct GPA values after updates while having the code still run the same. .6 4 Eile Edit View Build
getGPA() needs to continues to return correct GPA values after updates while having the code still run the same.
.6 4 Eile Edit View Build Project Settings Tools Window Help a66 X ANILHEU +16 Y 1 public class GPACalculator{ 2 3 private double gpatotal; private int numCredits; 5 private double gpaToAdd; private int creditsToAdd; 7 8 public GPACalculator() { 9 gpaTotal = 0.0; 10 numCredits = 0; 11 gpaToAdd = 0.0; 12 creditsToAdd = 0; 13 } 14 15 public double addNewGradeToGPA( double gpaToAdd, int creditsToAdd) { 16 this.gpa ToAdd=gpaToAdd; 17 this.creditsToAdd-creditsToAdd; 18 this.gpaTotal+=this.gpaToAdd*this.creditsToAdd; 19 this.numCredits+=this.creditsToAdd; 20 return gpatotalumcredits; //Change this as needed 21 } 22 23 public double getGPA() { 24 return gpatotal; //Change this as needed 25 } 26 27 public int getCredits() { 28 return numCredits; //Change this as needed 29 } 30 L 31 public void reset() { 32 gpaTotal = 0.0; 33 numCredits = 0; 34 gpaToAdd = 0.0; 35 creditsToAdd = 0; 36 } 37 38 ) G GPACalcMain.java GPACalculator.java * ATIEG Status: running user program Line:30 Col:4 Code:0 Top:1 OVS BLKStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started