C:\Users\gator\Documents\InventoryPart1.java:101: cannot find symbol
symbol : constructor Television(java.lang.String,java.lang.String,int,double)
location: class Television
Television sony = new Television ("SONY368", "Sony Vega", 2, 899.99);
^
1錯誤 這是錯誤,我得到當我試圖編譯下面我java代碼:我需要知道什麼,以便爲它編寫任何人都可以幫助改變?我不明白錯誤消息中的int。的Java編程庫存
//Author: Walter Rutherford
//Date: Feb. 03/2011
//Class: IT/215 week five inventory program 1
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;
class Television {
private String itemNumber;
private String productName;
private double units;
private double unitPrice;
private double unitsTotal;
//constructor
public Television (String itemNumber, String productName, double units, double unitprice, double unitsTotal) {
setItemNumber(itemNumber);
setProductName(productName);
setUnits(units);
setUnitPrice(unitPrice);
unitsTotal = units ++;
}
//accessor methods for class variables
public String getItemNumber() {
return itemNumber;
}
public void setItemNumber (String itemNumber) {
this.itemNumber = itemNumber;
}
public String getProductName() {
return productName;
}
public void setProductName (String productName) {
this.productName = productName;
}
public double getUnits() {
return units;
}
public void setUnits (double units) {
this.units = units;
}
public double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice (double unitPrice) {
this.unitPrice = units * unitPrice;
}
public double getUnitsTotal() {
return unitsTotal;
}
public void setUnitsTotal (double unitsTotal) {
this.unitsTotal = units ++;
}
}
public class InventoryPart1 {
public static void main (String args[]) {
int units;
double unitPrice;
double unitsTotal;
unitsTotal = units ++;
double unitsPrice;
unitsPrice = units * unitPrice;
double unitsTotalPrice;
unitsTotalPrice = unitsTotal * unitPrice;
double totalInventory;
totalInventory = unitsTotal * unitsTotalPrice;
NumberFormat nf = NumberFormat. getCurrencyInstance(Locale.US);
//create an instance of the Television class
Television sony = new Television ("SONY368", "Sony Vega", 2, 899.99);
//use the methods from class Television to output the inventory details.
System.out.println("Item Number: " + sony.getItemNumber());
System.out.println("Product Name: " + sony.getProductName());
System.out.print("Number of Units: ");
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("Total Inventory: ");
System.out.println(nf.format(totalInventory));
}
}
如果這是一項家庭作業,它應該有`家庭作業`標籤,我認爲。 – 2011-02-06 03:22:53