| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 490 人关注过本帖
标题:求助,一个程序一直犯同样的错误就是不知道怎么改
取消只看楼主 加入收藏
hugfemale
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-11-20
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求助,一个程序一直犯同样的错误就是不知道怎么改
程序代码:
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
求助这个程序应该怎样改才是正确的
搜索更多相关主题的帖子: Enter 
2013-11-20 15:26
hugfemale
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-11-20
收藏
得分:0 
回复 4楼 琢石成器
怎样改变,让这个程序变成class{};public class{}的形式呢?class里面储存5个数 publicclass里面计算? 自己改了很久没有成功,真心求教
2013-11-20 22:43
快速回复:求助,一个程序一直犯同样的错误就是不知道怎么改
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012238 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved