I am having trouble figuring out my code and was hoping someone could point me in the right direction. Below is my code what I need to due is create a method to add and display the value of the entire inventory. I have what I think is the correct code but it's not working. Help is greatly appreciated

class Inventory3
{
	public static final int MAXIMUM_ITEMS = 4;
	private static Product product[] = new Product[MAXIMUM_ITEMS];
	
		public static void main(String args[]) 
			{
				buildInventory();
				getInventory();		
			}

		// Build the inventory, storing 10 different products.
		public static void buildInventory() 
			{
				product[0] = new Product(1001, "Megaforce", 10, 18.95);
				product[1] = new Product(502, "Abyss", 25, 12.95);
				product[2] = new Product(1003, "Deep Impact", 65, 21.95);
				product[3] = new Product(750, "Forest Gump", 28, 7.95);
				Arrays.sort(product);			   
			}

	public static void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
					System.out.println("Item Name: " + product[i].getItemName());
					System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
					System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
					System.out.println();
										
				}
		}
		
	public double entireValue() 
		{
			double value = 0;
				for (int i = 0; i < Product; i++) 
				{
				value = value + product[i].getValue();
				}
			return value;
		}

	public void display() 
		{
		System.out.printf("Total Value is: $%.2f\n\n", entireValue());
		}
			
	
} //end Class Inventory3

Below is the error I get when I try to complie this into my code
Inventory3.java:104: cannot find symbol
symbol : variable Product
location: class Inventory3
for (int i = 0; i < Product; i++)
^
1 error

here is my complete working code so far

import java.util.Arrays;

class Product implements Comparable
{
		private long itemNumber;	// class variable that stores the item number
		private String itemName;	// class variable that stores the item name
		private long invQuantity;   // class variable that stores the quantity in stock
		private double itemPrice;   // class variable that stores the item price
			
			public Product(long number, String name, long quantity, double price) // Constructor for the Supplies class
				{
					itemNumber = number;
					itemName = name;
					invQuantity = quantity;
					itemPrice = price;
				}
			
			public long getItemNumber() { return itemNumber; } // Method to set item number
			public String getItemName() { return itemName;} // Method to set the item name
			public long getInvQuantity() { return invQuantity;} // Method to set the quantity in stock
			public double getItemPrice() { return itemPrice;} // Method to get the item Price
			
			public double getValue() { return (double) invQuantity * itemPrice; } // Method to calculate the valure of the inventory
			
	public int compareTo(Object o)
		{
			Product p = null;
				try
					{
						p = (Product) o;
					}
						
				catch (ClassCastException cE)
					{
						cE.printStackTrace();
					}
				return itemName.compareTo(p.getItemName());
		}
}  //end class Product

class DVD extends Product 
	{
		public DVD(int itemNumber, String itemName, long invQuantity, double itemPrice) 
		{
			super(itemNumber, itemName, invQuantity, itemPrice);
		}

	   public double getValue() 
	   {
		double inventoryValue = super.getValue();
		return (inventoryValue * 1.05);
		}	
}

class Inventory3
{
	public static final int MAXIMUM_ITEMS = 4;
	private static Product product[] = new Product[MAXIMUM_ITEMS];
	
		public static void main(String args[]) 
			{
				buildInventory();
				getInventory();		
			}

		// Build the inventory, storing 10 different products.
		public static void buildInventory() 
			{
				product[0] = new Product(1001, "Megaforce", 10, 18.95);
				product[1] = new Product(502, "Abyss", 25, 12.95);
				product[2] = new Product(1003, "Deep Impact", 65, 21.95);
				product[3] = new Product(750, "Forest Gump", 28, 7.95);
				Arrays.sort(product);			   
			}

	public static void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
					System.out.println("Item Name: " + product[i].getItemName());
					System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
					System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
					System.out.println();
										
				}
		}
		
} //end Class Inventory3
Inventory3.java:104: cannot find symbol
symbol : variable Product

The key word above is "variable". The compiler is looking for a variable. Product is not a variable, it is a class:

class Product implements Comparable

You are using it as a variable by comparing it to the integer variable i:

for (int i = 0; i < Product; i++)

You refer to i below as an index of "product", not "Product". "product" IS a variable, but it is an array and cannot be compared to an integer, so you still cannot compare i to "product" above either.

product[i].getItemNumber());

Observe how the i is being used above. It is being used as index of an array, which is its proper use. You want to compare i to the number of elements in the product array in the line below, not "Product". So how many elements are in the array "product"? You need to replace "Product" below with something that represents the size of the product array.

for (int i = 0; i < Product; i++)

Would I need to create a counter to determine how many items there are? I know there are 4 items in the array but I can't put

for (int i = 0; i < 4; i++)

can i?

Would I need to create a counter to determine how many items there are? I know there are 4 items in the array but I can't put

for (int i = 0; i < 4; i++)

can i?

Well, you can certainly put that, but you are correct, it is probably a better idea to declare a counter variable, such as sizeOfArray, initialize it to 0, then increment it every time you assign a new element to the array, or just assign sizeOfArray to 4 at the end, like this, in your particular case since it's all happening at once:

product[0] = new Product(1001, "Megaforce", 10, 18.95);
product[1] = new Product(502, "Abyss", 25, 12.95);
product[2] = new Product(1003, "Deep Impact", 65, 21.95);
product[3] = new Product(750, "Forest Gump", 28, 7.95);
sizeOfArray = 4;

sizeOfArray would be declared as an integer in the same area of the code that the product array is declared. Then replace the 4 in your for-loop with sizeOfArray.

Well, you can certainly put that, but you are correct, it is probably a better idea to declare a counter variable, such as sizeOfArray, initialize it to 0, then increment it every time you assign a new element to the array, or just assign sizeOfArray to 4 at the end, like this, in your particular case since it's all happening at once:

product[0] = new Product(1001, "Megaforce", 10, 18.95);
product[1] = new Product(502, "Abyss", 25, 12.95);
product[2] = new Product(1003, "Deep Impact", 65, 21.95);
product[3] = new Product(750, "Forest Gump", 28, 7.95);
sizeOfArray = 4;

sizeOfArray would be declared as an integer in the same area of the code that the product array is declared. Then replace the 4 in your for-loop with sizeOfArray.

ok so that worked I'm able to complie the code now but I do not get a display of the entire inventory value. I've tried calling the value display high in my program and I get an error message saying it's not been delcared. Here is my updated code, I just don't see what I'm missing to get it to display.

class Inventory3
{
	public static final int MAXIMUM_ITEMS = 4;
    private static Product product[] = new Product[MAXIMUM_ITEMS];
	public static int sizeOfArray;
	
        public static void main(String args[]) 
			{
                buildInventory();
                getInventory();        
			}

        // Build the inventory, storing 10 different products.
    public static void buildInventory() 
		{
            product[0] = new Product(1001, "Megaforce", 10, 18.95);
            product[1] = new Product(502, "Abyss", 25, 12.95);
            product[2] = new Product(1003, "Deep Impact", 65, 21.95);
            product[3] = new Product(750, "Forest Gump", 28, 7.95);
			sizeOfArray = 4;
			Arrays.sort(product);               
		}

	public static void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
                    System.out.println("Item Name: " + product[i].getItemName());
                    //System.out.println("Director: " + product[i].getDirector());
					System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                    System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                    System.out.println();
										
				}
	
		}
		
		
	public double entireValue() 
		{
			double value = 0;
				for (int i = 0; i < sizeOfArray; i++) 
				{
				value = value + product[i].getValue();
				}
			return value;
		}

	public void display() 
		{
        System.out.printf("Total Value is: $%.2f\n\n", + entireValue());
		}
			
	
} //end Class Inventory3

Here is what displays
Welcome to DVD Inventory 1.0

Item Number: 502
Item Name: Abyss
Inventory On Hand: 25
Item Price: $12.95
Value of Inventory: $323.75
Restock Fee: $16.1875

Item Number: 1003
Item Name: Deep Impact
Inventory On Hand: 65
Item Price: $21.95
Value of Inventory: $1426.75
Restock Fee: $71.3375

Item Number: 750
Item Name: Forest Gump
Inventory On Hand: 28
Item Price: $7.95
Value of Inventory: $222.6
Restock Fee: $11.13

Item Number: 1001
Item Name: Megaforce
Inventory On Hand: 10
Item Price: $18.95
Value of Inventory: $189.5
Restock Fee: $9.475

What is it not displaying that it is supposed to display (aside from the problem of having too few or too many decimal points)?

What is it not displaying that it is supposed to display (aside from the problem of having too few or too many decimal points)?

It should display a line of code at the bottom with " Total Value is: $xxxxx"

that value is the total of each dvd's total inventory value added up. for a Total Inventory value.

what should display is this (I totaled it myself and added the text for reference)
Welcome to DVD Inventory 1.0

Item #: 502
Name: Abyss
Quantity: 25
Price: $12.95
Value: $323.75

Item #: 1003
Name: Deep Impact
Quantity: 65
Price: $21.95
Value: $1426.75

Item #: 750
Name: Forest Gump
Quantity: 28
Price: $7.95
Value: $222.6

Item #: 1001
Name: Megaforce
Quantity: 10
Price: $18.95
Value: $189.5


Total Value is: $2162.6

It should display a line of code at the bottom with " Total Value is: $xxxxx"

that value is the total of each dvd's total inventory value added up. for a Total Inventory value.

what should display is this (I totaled it myself and added the text for reference)
Welcome to DVD Inventory 1.0

Item #: 502
Name: Abyss
Quantity: 25
Price: $12.95
Value: $323.75

Item #: 1003
Name: Deep Impact
Quantity: 65
Price: $21.95
Value: $1426.75

Item #: 750
Name: Forest Gump
Quantity: 28
Price: $7.95
Value: $222.6

Item #: 1001
Name: Megaforce
Quantity: 10
Price: $18.95
Value: $189.5


Total Value is: $2162.6

Well, if it is supposed to display that through a call to the function called "display" in the Inventory3 class, I don't see where you ever call that function.

Well, if it is supposed to display that through a call to the function called "display" in the Inventory3 class, I don't see where you ever call that function.

I create the value and then call it below it

public double entireValue() 
		{
			double value = 0;
				for (int i = 0; i < sizeOfArray; i++) 
				{ value = value + product[i].getValue(); }
			return value;
		}

	public void display() 
		{
        System.out.printf("Total Value is: $%.2f\n\n", + entireValue());
		}

I create the value and then call it below it

public double entireValue() 
{
	double value = 0;
	for (int i = 0; i < sizeOfArray; i++) 
	{
              value = value + product[i].getValue(); 
        }
	return value;
}

public void display() 
{
        System.out.printf("Total Value is: $%.2f\n\n", + entireValue());
}

I see the display function, but I don't see a call to the display function.

I'm a little lost at this point. isn't this my call?

public void display() 
{
        System.out.printf("Total Value is: $%.2f\n\n", + entireValue());
}

I also added a line earlier in the display section where everything else displays and I get an error here is my updated code

class Inventory3
{
    public static final int MAXIMUM_ITEMS = 4;
    private static Product product[] = new Product[MAXIMUM_ITEMS];
    public static int sizeOfArray;

        public static void main(String args[]) 
            {
                buildInventory();
                getInventory();        
            }

        // Build the inventory, storing 10 different products.
    public static void buildInventory() 
        {
            product[0] = new Product(1001, "Megaforce", 10, 18.95);
            product[1] = new Product(502, "Abyss", 25, 12.95);
            product[2] = new Product(1003, "Deep Impact", 65, 21.95);
            product[3] = new Product(750, "Forest Gump", 28, 7.95);
            sizeOfArray = 4;
            Arrays.sort(product);               
        }

    public static void getInventory() 
        {
            System.out.println(); // blank line
            System.out.println("Welcome to DVD Inventory 1.0"); //display header
            System.out.println();
            for(int i = 0; i < product.length; i++) 
                {
                    System.out.println("Item Number: " + product[i].getItemNumber());
                    System.out.println("Item Name: " + product[i].getItemName());
                    System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                    System.out.println("Item Price: $" + product[i].getItemPrice());
                    System.out.println("Value of Inventory: $" + product[i].getValue());
                    System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                    System.out.println();

                }
            [icode]System.out.println("Total Value is: $" + entireValue);[/icode]
        }

    double entireValue() 
        {
            double value = 0;
                for (int i = 0; i < sizeOfArray; i++) 
                { value = value + product[i].getValue(); }
            return value;
        }

    public void display() 
        {
            System.out.printf("Total Value is: $%.2f", + entireValue());
        }

} //end Class Inventory3

and this is the error I get

Inventory3.java:100: cannot find symbol
symbol  : variable entireValue
location: class Inventory3
                        System.out.println("Total Value is: $" + entireValue);
                    ^
1 error

Do i need to create a value and have it overwrite so I can call it?

I'm a little lost at this point. isn't this my call?

public void display() 
{
        System.out.printf("Total Value is: $%.2f\n\n", + entireValue());
}

No, that's a call to the entireValue function FROM your display function. That is your display function itelf. There is no call to your display function. Looks to me like you should be calling your display function from your getInventory function. Simply add this to the end of your getInventory function:

display();

THAT'S the call to the display function.

Before you can do that though, you have too many static functions. You need to add a constructor to your Inventory3 class. It doesn't need to do anything necessarily, but it should be there:

public Inventory3 ()
{
}

Change your main function to this:

public static void main(String args[]) 
{
     Inventory3 inventory = new Inventory3 ();
     inventory.buildInventory();
     inventory.getInventory();        
}

Run your program. You'll get some complaints from the compiler about your static functions. Change functions from static to non-static one at a time corresponding to the error messages, then recompile each time, till you get no more errors and it looks right.

Run your program. You'll get some complaints from the compiler about your static functions. Change functions from static to non-static one at a time corresponding to the error messages, then recompile each time, till you get no more errors and it looks right.

So I've added what I think is correct and oddly enough I don't get any messages about static functions.

public class Inventory3
{
	public static final int MAXIMUM_ITEMS = 4;
    private static Product product[] = new Product[MAXIMUM_ITEMS];
	public static int sizeOfArray;
		
		public static void main(String args[])
			{
				Inventory3 inventory = new Inventory3 ();
				inventory.buildInventory();
				inventory.getInventory();
			}
	
        public static void main(String args[]) 
			//{
               //buildInventory();
                //getInventory();        
			//}

        // Build the inventory, storing 10 different products.
    public static void buildInventory() 
		{
            product[0] = new Product(1001, "Megaforce", 10, 18.95);
            product[1] = new Product(502, "Abyss", 25, 12.95);
            product[2] = new Product(1003, "Deep Impact", 65, 21.95);
            product[3] = new Product(750, "Forest Gump", 28, 7.95);
			sizeOfArray = 4;
			Arrays.sort(product);               
		}

	public static void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
                    System.out.println("Item Name: " + product[i].getItemName());
                    System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                    System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                    System.out.println();
										
				}
			//System.out.println("Total Value is: $" + entireValue);
		}
		
	double entireValue() 
		{
			double value = 0;
				for (int i = 0; i < sizeOfArray; i++) 
				{ value = value + product[i].getValue(); }
			return value;
		}

	public void display() 
		{
			System.out.printf("Total Value is: $%.2f", + entireValue());
		}
			
} //end Class Inventory3

I'm assuming I don't have it correct or I don't understand where to put the display(); as I had it in several different places and that's the only error I got was I can't use a static display

So I've added what I think is correct and oddly enough I don't get any messages about static functions.

public class Inventory3
{
	public static final int MAXIMUM_ITEMS = 4;
    private static Product product[] = new Product[MAXIMUM_ITEMS];
	public static int sizeOfArray;
		
		public static void main(String args[])
			{
				Inventory3 inventory = new Inventory3 ();
				inventory.buildInventory();
				inventory.getInventory();
			}
	
        public static void main(String args[]) 
			//{
               //buildInventory();
                //getInventory();        
			//}

        // Build the inventory, storing 10 different products.
    public static void buildInventory() 
		{
            product[0] = new Product(1001, "Megaforce", 10, 18.95);
            product[1] = new Product(502, "Abyss", 25, 12.95);
            product[2] = new Product(1003, "Deep Impact", 65, 21.95);
            product[3] = new Product(750, "Forest Gump", 28, 7.95);
			sizeOfArray = 4;
			Arrays.sort(product);               
		}

	public static void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
                    System.out.println("Item Name: " + product[i].getItemName());
                    System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                    System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                    System.out.println();
										
				}
			//System.out.println("Total Value is: $" + entireValue);
		}
		
	double entireValue() 
		{
			double value = 0;
				for (int i = 0; i < sizeOfArray; i++) 
				{ value = value + product[i].getValue(); }
			return value;
		}

	public void display() 
		{
			System.out.printf("Total Value is: $%.2f", + entireValue());
		}
			
} //end Class Inventory3

I'm assuming I don't have it correct or I don't understand where to put the display(); as I had it in several different places and that's the only error I got was I can't use a static display

Comment out that second main function entirely. You still have the first line there. Did this compile and run? Put the display () call in as the last line of the getInventory function. It doesn't look like you added the Inventory3 () constructor either. Often it doesn't matter, but it really should be there to be safe. Recompile and rerun it and see what you get. Also, your code would be more readable if you formatted the indentation more consistently. If you aren't using an IDE like NetBeans or something else, an IDE can be pretty handy if for no other reason than it will format code for you.

Comment out that second main function entirely. You still have the first line there.

What line are you talking about?

Did this compile and run? Put the display () call in as the last line of the getInventory function.

Yes it complied and ran but still did not display anything.

I've added the display(); at the end of getInventory

public static void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
                    System.out.println("Item Name: " + product[i].getItemName());
					System.out.println("Item Director: " );
					System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                    System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                    System.out.println();
										
				}
			System.out.println("Total Value is: $" );
			display();
		}

here is the error I get
Inventory3.java:124: non-static method display() cannot be referenced from a static context
display();
^
1 error

It doesn't look like you added the Inventory3 () constructor either. Often it doesn't matter, but it really should be there to be safe. Recompile and rerun it and see what you get.

Not sure what you mean I added public class Inventory3, do you want me to just add it in after my getInventory() call:

Also, your code would be more readable if you formatted the indentation more consistently. If you aren't using an IDE like NetBeans or something else, an IDE can be pretty handy if for no other reason than it will format code for you.

I'm using notepad ++ I know it's not an IDE but I have tried NetBeans and I don't understand it, and haven't really had time to learn it. I am indenting my code and keeping my {}'s lined up so I can see my endings. I may not be using the code tags correct when I post to the site if that's what you mean.

public class Inventory3
{
	public static final int MAXIMUM_ITEMS = 4;
    private static Product product[] = new Product[MAXIMUM_ITEMS];
	public static int sizeOfArray;
		
		public static void main(String args[])
			{
				Inventory3 inventory = new Inventory3 ();
				inventory.buildInventory();
				inventory.getInventory();
			}
	
        public static void main(String args[]) 
			//{
               //buildInventory();
                //getInventory();        
			//}

        // Build the inventory, storing 10 different products.
    public static void buildInventory() 
		{
            product[0] = new Product(1001, "Megaforce", 10, 18.95);
            product[1] = new Product(502, "Abyss", 25, 12.95);
            product[2] = new Product(1003, "Deep Impact", 65, 21.95);
            product[3] = new Product(750, "Forest Gump", 28, 7.95);
			sizeOfArray = 4;
			Arrays.sort(product);               
		}

	public static void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
                    System.out.println("Item Name: " + product[i].getItemName());
                    System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                    System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                    System.out.println();
										
				}
			//System.out.println("Total Value is: $" + entireValue);
		}
		
	double entireValue() 
		{
			double value = 0;
				for (int i = 0; i < sizeOfArray; i++) 
				{ value = value + product[i].getValue(); }
			return value;
		}

	public void display() 
		{
			System.out.printf("Total Value is: $%.2f", + entireValue());
		}
			
} //end Class Inventory3

What line are you talking about?

Line 14 above. Comment it out.

I've added the display(); at the end of getInventory

Good. You have it in the proper place.

here is the error I get
Inventory3.java:124: non-static method display() cannot be referenced from a static context
display();

^
That's the error I was talking about in my last post. Start changing your static functions to non-static functions one by one and recompiling till the error(s) go away.

Not sure what you mean I added public class Inventory3, do you want me to just add it in after my getInventory() call:

Regarding the Inventory3 constructor, you have a call to the default Inventory3 constructor in line 9, but I don't see the constructor itself anywhere. Add something like this around line 19:

public Inventory3 ()
{
}

I'm using notepad ++ I know it's not an IDE but I have tried NetBeans and I don't understand it, and haven't really had time to learn it. I am indenting my code and keeping my {}'s lined up so I can see my endings. I may not be using the code tags correct when I post to the site if that's what you mean.

Lines 3, 4, 5, 7, 14, and 21 should all line up, as lines 23 through 26 do. It makes the code much more readable. Make sure you use a consistent width font like Courier if font is an option. Use tabs or spaces, but be careful if you intermingle the two, especially if you take it from notepad++ and paste it here. The number of spaces in a tab may be different here and there. Hit the "Preview Post" key to see what it looks like. Everything within a certain block of code should be at the same indentation. It's much more readable that way.

Regarding the Inventory3 constructor, you have a call to the default Inventory3 constructor in line 9, but I don't see the constructor itself anywhere. Add something like this around line 19:

public Inventory3 ()
{
}

end quote.

Ok i've added the Inventory3 constructor and removed that static statements and now I get an error message I don't understand.

public class Inventory3
{
    public static final int MAXIMUM_ITEMS = 4;
        private static Product product[] = new Product[MAXIMUM_ITEMS];
    public static int sizeOfArray;

    public static void main(String args[])
        {
            Inventory3 inventory = new Inventory3 ();
            inventory.buildInventory();
            inventory.getInventory();
        }

        public Inventory3();
        {
        }
        public void buildInventory() 
        {
            product[0] = new Product(1001, "Megaforce", 10, 18.95);
            product[1] = new Product(502, "Abyss", 25, 12.95);
            product[2] = new Product(1003, "Deep Impact", 65, 21.95);
            product[3] = new Product(750, "Forest Gump", 28, 7.95);
            sizeOfArray = 4;
            Arrays.sort(product);               
        }

    public void getInventory() 
        {
            System.out.println(); // blank line
            System.out.println("Welcome to DVD Inventory 1.0"); //display header
            System.out.println();
            for(int i = 0; i < product.length; i++) 
                {
                    System.out.println("Item Number: " + product[i].getItemNumber());
                                        System.out.println("Item Name: " + product[i].getItemName());
                    System.out.println("Item Director: " );
                    System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                                        System.out.println("Item Price: $" + product[i].getItemPrice());
                    System.out.println("Value of Inventory: $" + product[i].getValue());
                    System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                                        System.out.println();

                }
            System.out.println("Total Value is: $" );
            display();
        }

    double entireValue() 
        {
            double value = 0;
                for (int i = 0; i < sizeOfArray; i++) 
                { value = value + product[i].getValue(); }
            return value;
        }

    public void display() 
        {
            System.out.printf("Total Value is: $%.2f", + entireValue());
        }

} //end Class Inventory3

Error:

Inventory3.java:121: missing method body, or declare abstract
        public Inventory3();
                 ^
1 error

I think you should get rid of the semi-colon in red.

public Inventory3();

{

}

Jasimp,

That worked thank you! Now I need to tackle my next problem, which is adding a director to this whole thing.

Ok so here is my latest problem, I had been working on this code as well on another project and I'm able to append the String so that it will read the added "Director" field. I have passed itemDirector as public along with getItemDirector. My error is in my call to product.getItemDirector. Below is my code and the error, again any direction is greatly appreciated, my other program display's "null" with almost the same code so I know i'm close.

class DVD extends Product
{
	public String itemDirector;    // class variable that stores the item name
	public DVD(int itemNumber, String itemName, String itemDirector, long invQuantity, double itemPrice) 
		{
			super(itemNumber, itemName, invQuantity, itemPrice);
			itemDirector = itemDirector;
		}
	public String getItemDirector() { return itemDirector;} // Method to set the item name	
	
    public double getValue() 
	    {
			double inventoryValue = super.getValue();
			return (inventoryValue * 1.05);
		}
		
}

Below is my updated Inventory3 with the call

public class Inventory3
{
	public static final int MAXIMUM_ITEMS = 4;
        private static Product product[] = new Product[MAXIMUM_ITEMS];
	public static int sizeOfArray;
		
	public static void main(String args[])
		{
			Inventory3 inventory = new Inventory3 ();
			inventory.buildInventory();
			inventory.getInventory();
		}
	
    public Inventory3()
		{
		}
    public void buildInventory() 
		{
            product[0] = new DVD(1001, "Megaforce", "Hal Needham", 10, 18.95);
            product[1] = new DVD(502, "The Abyss", "James Cameron", 25, 12.95);
            product[2] = new DVD(1003, "Deep Impact", "Mimi Leder", 65, 21.95);
            product[3] = new DVD(750, "Forest Gump", "Robert Zemeckis",28, 7.95);
			sizeOfArray = 4;
			Arrays.sort(product);               
		}

	public void getInventory() 
		{
			System.out.println(); // blank line
			System.out.println("Welcome to DVD Inventory 1.0"); //display header
			System.out.println();
			for(int i = 0; i < product.length; i++) 
				{
					System.out.println("Item Number: " + product[i].getItemNumber());
                    System.out.println("Item Name: " + product[i].getItemName());
					System.out.println("Item Director: " + product[i].getItemDirector());
					System.out.println("Inventory On Hand: " + product[i].getInvQuantity());
                    System.out.println("Item Price: $" + product[i].getItemPrice());
					System.out.println("Value of Inventory: $" + product[i].getValue());
					System.out.println("Restock Fee: $" + (product[i].getValue()) * 0.05);
                    System.out.println();
										
				}
			//System.out.println("Total Value is: $" );
			display();
		}
		
	double entireValue() 
		{
			double value = 0;
				for (int i = 0; i < sizeOfArray; i++) 
				{ value = value + product[i].getValue(); }
			return value;
		}

	public void display() 
		{
			System.out.printf("Total Value is: $%.2f", + entireValue());
		}
			
} //end Class Inventory3

Here is the error i'm getting
Inventory3.java:100: cannot find symbol
symbol : method getItemDirector()
location: class Product
System.out.println("Item Director: " + product.getItemDirector());
^
1 error

I'm not passing the getItemDirector down to Inventory3 am I?

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.