I keep getting a"Can't find symbol" error and code will not compile.
Assignment already late and need help ASAP.

//Inventory Program Part 3
//IT215 week 6


class Inventory { 

	String itemNumber; //stores item number
	String name; //stores name
        int stockQuantity; //stores quanity in stock
	double pricePerunit; //stores  price
	String departmentName;//Department name

	public Inventory(String Item_Number, String Item_Name,  int Items_in_Stock, String Department_Name, double Item_Price)
	{
		itemNumber = Item_Number;
		name = Item_Name;
                departmentName = Department_Name;
                stockQuantity = Items_in_Stock;
		pricePerunit = Item_Price;
		
	              }

	public void setItemName(String Item_Name) //set and get the item name
	{
		name = Item_Name;
	}
	public String getItemName()
	{
		return name;
	}
          
	public void setItemNumber(String Item_Number) //set and get the item number
	{
		itemNumber = Item_Number;
	}
	public String getItemNumber()
	{
		return itemNumber;
	}

	public void setItemsInStock(int Items_in_Stock) //set and get quantity in stock
	{
		stockQuantity = Items_in_Stock;
	}
	public int getItemsInStock()
	{
		return stockQuantity;
	}

	public void setItemPrice(double Item_Price) //set and get the item price
	{
		pricePerunit = Item_Price;
	}
	public double getItemPrice()
	{
		return pricePerunit;
	}

		public double getInventoryValue() //value of stock inventory
	{
		return pricePerunit * stockQuantity;
         }
         public void setdepartmentName(String Department)
         {
              departmentName = Department_Name;
          }

      	public static double getTotalValueOfAllInventory(Inventory [] inv)
	{
		double tot = 0.00;

		for(int i = 0; i < inv.length; i++)
		{
		tot += inv[i].getInventoryValue();
		}
		return tot;
	}

    @Override
	public String toString()
	{
	return "Product: "+name + "\nItem Number: "+itemNumber+"\nItem Price: $"+pricePerunit + "\nInventory Value: +\n Department $"+getInventoryValue();
	}
} // end Inventory Class


class Product extends Inventory {

	 String Namebrand;	// Subclass to Camera Products
              

                  // initialize Product constructor
	public Product(String Namebrand, String Item_Number, String Item_Name, String Department_Name, int Items_in_Stock,
			double Item_Price)
        {
		super(Item_Number, Item_Name, Item_Price, Department_Name, Items_in_Stock);
		this.Namebrand = Namebrand;
		
	}

    @Override
	public String toString()
	{
		StringBuffer sb = new StringBuffer("\nNamebrand: ").append(Namebrand).append("\n");
		sb.append(super.toString());

		return sb.toString();
	}

} // End Product Class

public class Inventory3

{
	public static void main(String args[])
	{
                
		Product[] inventory = new Product[4]; //create array of Camera Products

		inventory[0] = new Product("Canon" , "1","Sureshot" , 50, 99.99, "Department");
		inventory[1] = new Product("Nikon" , "2","Digital" , 7,  89.50,"Department");
		inventory[2] = new Product("Rocoh", "3","Reflections", 6,  79.75,"Department");
		inventory[3] = new Product("HP", "4","Digital" , 7, 69.00, "Department");

		Product temp[] = new Product[1];

		 System.out.print( "Inventory of Camera Products " ); // display title
   		 System.out.println();
   		 System.out.println();


// Sorting Inventory Information
		for(int j = 0; j < inventory.length - 1; j++)
		{
		    for(int k = 0; k < inventory.length - 1; k++)
		    {
		        if(inventory[k].getItemName().compareToIgnoreCase(inventory[k+1].getItemName()) > 0)
		        {
		            temp[0] = inventory[k];
		            inventory[k] = inventory[k+1];
		            inventory[k+1] = temp[0];
		        }
		    }
		}

// Print Inventory Information
		for(int j = 0; j < inventory.length; j++)
		{
			System.out.println(inventory[j].toString());
		}


		System.out.printf("\n\nTotal value of inventory: $%.2f\n\n" , Inventory.getTotalValueOfAllInventory(inventory));
		return;

	}
} // End Inventory3 Class

Recommended Answers

All 2 Replies

Getting error on line 65,96,120,121,122,123.

Then you need to look at your code on those lines.

public void setdepartmentName(String Department) {
  departmentName = Department_Name;  // line 65 is here
  // The problem is that Department_Name is expected to be a variable,
  // but your function has only Department argument passed in;
  // as a result, the compiler doesn't know what Department_Name is.
}

// line 96
super(Item_Number, Item_Name, Item_Price, Department_Name, Items_in_Stock);
// Check back to your Inventory constructor.
// It takes (String, String, int, String, double),
// but you are using (String, String, double, String, int).
// I would suggest you to look at how Inventory constructor is implemented,
// and correctly adjust your variables passing into the constructor

// line 120~123
inventory[0] = new Product("Canon" , "1","Sureshot" , 50, 99.99, "Department");
inventory[1] = new Product("Nikon" , "2","Digital" , 7,  89.50,"Department");
inventory[2] = new Product("Rocoh", "3","Reflections", 6,  79.75,"Department");
inventory[3] = new Product("HP", "4","Digital" , 7, 69.00, "Department");
// Where is your Product.class file? Is it in the same folder location as your Inventory3.class?
// The compiler complains because it cannot find Product class.

Please read what the error caught by the compiler and try to fix it from there line by line. This is why the error with line number is for...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.