Question: Error in my java code on the sum + = value; portion of my code. I do not know what or why the syntax error

Error in my java code on the sum += value; portion of my code. I do not know what or why the syntax error is being thrown. My code is below:
import java.util.Scanner;
public class Main {
public static void main(String[] args){
double[] values = inputValues();
double average = calculateAverage(values);
printAverage(average);
}
public static double[] inputValues(){
Scanner scanner = new Scanner(System.in);
double[] values = new double[3];
System.out.println("Enter three double values: ");
for (int i =0; i<3, i++){
System.out.print("Value"+(i+1)+":");
values[i]= scanner.nextDouble();
}
return values;
}
public static double calculatAverage (double[] values){
double sum =0;
for (double value : values){
sum += value; //THIS CODE LINE IS GIVING ME A SYNTAX ERROR, BUT APPEARS CORRECT. WHAT AM I MISSING?
}
return sum / values.length;
}
public static void printAverage(double average){
System.out.println("The average of the three values is: "+ average);
}
}

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 Accounting Questions!