求助,一个程序一直犯同样的错误就是不知道怎么改
程序代码:
import java.util.Scanner; class StatisticsCalculator { private double n1,n2,n3,n4,n5; Scanner scanner; public StatisticsCalculator() { Scanner Kb = new Scanner(System.in); System.out.println("Enter the cost on Monday:"); double n1 = Kb.nextDouble(); System.out.println("Enter the cost on Tuesday:"); double n2 = Kb.nextDouble(); System.out.println("Enter the cost on Wednesday:"); double n3 =Kb.nextDouble(); System.out.println("Enter the cost on Thursday:"); double n4 = Kb.nextDouble(); System.out.println("Enter the cost on Friday:"); double n5 = Kb.nextDouble(); } public void setCost(double n1,double n2,double n3,double n4,double n5) { } public double getCost() { List list = new ArrayList(); list.add(n1); list.add(n2); list.add(n3); list.add(n4); list.add(n5); return list; } }; public class TestStatisticsCalculator { public static void main(String[] args) { TestStatisticsCalculator a=new TestStatisticsCalculator(); a.sum(); a.average(); System.out.println("the cost of total fuel is: "+total); System.out.println("the cost of average fuel is:"+ mean); } public static void sum() { total=n1+n2+n3+n4+n5; return total; } public static void average() { mean=(n1+n2+n3+n4+n5)/5; return mean; } } 其实就是要求输入五个数字 求平均值和总数。 但是我只会最简单的,不会这个样子的编程。 应该有两个错误,一个是class里面 return和list不知道怎么使用。 第二是public class 无法使用class里面的n1n2n3n4n5 求助这个程序应该怎样改才是正确的