我在旁边遇到一个非法的表达式开始错误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;
}
}
}