我有2条错误消息,无法确定它在问我什么。错误是:

Desktop \ Inventory Program \ InventoryPart1.java:93:找不到符号
符号:可变打印机
位置:类InventoryPart1
        System.out.println(“ Item Number:” + printer.getItemNumber());

Desktop \ Inventory Program \ InventoryPart1.java:95:找不到符号
符号:可变的打印机,请在此处输入代码。
位置:类InventoryPart1
        System.out.println(“产品名称:” + printer.getProductName());

到目前为止的代码是

导入java.text.NumberFormat;
导入java.util.locale;
导入java.util.Scanner;

类打印机{

    私有字符串itemNumber;
    私有字符串productName;
    私人双人间
    私人双人单价;
    私人双单位合计;
    //构造函数
    公共打印机(字符串itemNumber,字符串productName,双精度单位,双精度总计){
        setItemNumber(itemNumber);
        setProductName(productName);
        setUnits(单位);
        setUnitPrice(unitPrice);
        unitsTotal =单位++;
    }

    //类变量的访问器方法
    公共字符串getItemNumber(){
        返回itemNumber;
    }

    public void setItemNumber(字符串itemNumber){
        this.itemNumber = itemNumber;
    }

    公共字符串getProductName(){
        返回productName;
    }

    public void setProductName(字符串productName){
        this.productName = productName;
    }

    public double getUnits(){
        返回单位;
    }

    public void setUnits(双精度单位){
        this.units =单位;
    }

    public double getUnitPrice(){
        返回单价;
    }

    公共无效setUnitPrice(双倍unitPrice){
        this.unitPrice =单位* unitPrice;
    }

    public double getUnitsTotal(){
        返回单位合计;
    }

    public void setUnitsTotal(double unitsTotal){
        this.unitsTotal =单位++;
    }


}

公共类InventoryPart1 {

    公共静态void主(String args []){


        整数单位;

        单价的两倍;

        双单位合计;
        unitsTotal =单位++;

        双单位价格;
        unitPrice =单位* unitPrice;

        double unitsTotalPrice;
        unitsTotalPrice =单位总数*单位价格;

        总库存增加一倍;
        totalInventory =单位总数*单位总数价格;


        NumberFormat nf = NumberFormat。 getCurrencyInstance(Locale.US);

        //创建Printer类的实例
        打印机epson =新打印机(“ Epson579”,“多合一”,2、50.99);

        //使用Printer类中的方法输出清单详细信息。
        System.out.println(“ Item Number:” + printer.getItemNumber());

        System.out.println(“产品名称:” + printer.getProductName());

        System.out.print(“单位数:”);
        System.out.println(nf.format(units));

        System.out.print(“ Unit Price:”);
        System.out.println(nf.format(unitPrice));

        System.out.print(“ Units Total:”);
        System.out.println(nf.format(unitsTotal));

        System.out.print(“ Units Total Price:”);
        System.out.println(nf.format(unitsTotalPrice));

        System.out.print(“总库存:”);
        System.out.println(nf.format(totalInventory));
    }

}

抱歉,这个网站是新手,仍然尝试通过输入完整的代码来解决问题,

最佳答案

啊,您没有声明名为printer的变量。您将其称为epson

关于java - Java库存计划问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7217238/

10-11 02:22
查看更多