我在public static double getAverage (double average) {旁边遇到表达式错误的非法开始
我还收到double average = sum /(double) arr.length;旁边显示“变量平均数未使用”的错误
我一直在工作一段时间,我不知道该怎么做了。
有什么建议么?
import java.util.Scanner;
public class Average {
public static void main(String [] args){
Scanner input = new Scanner(System.in);
System.out.print("How many numbers you want to display: ");
int n=input.nextInt();
System.out.println("Enter array values: ");
int arr [] = new int[n];
int sum=0;
for(int i = 0; i < arr.length; i++) {
arr[i] = input.nextInt();
sum+=arr[i];
double average = sum / (double) arr.length;
public static double getAverage(double average){
System.out.println("Average value of array: " + average);
{
return average;
}
}
}