I have a program that takes in 5 test scores, averages them and then assigns a letter grade to the average. I can't seem to get it to calculate properly. Can anyone point me in the right direction?
Here is the method used for averaging:
public double calcAverage() { //calculate the average testscore double average = 0; for (int i=0; i<nums.length;i++) { average+=nums[i]; average/=nums.length; } //return the average score return average; }
Here is where I have the button event:
for(int i=0; i<txtNums.length; i++) { scan = new Scanner(txtNums[i].getText()); if(scan.hasNextDouble()) { nums[i] = scan.nextDouble(); output = calcAverage(); } else { nums[i] = 0; txtNums[i].setText(" Error "); error = true; } }