Here are the errors the compiler gives me. Really, I do not understand most of the errors that the compiler gives me. Here is what my code is supposed to do: Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory.
• Create a method to calculate the value of the entire inventory.
• Create another method to sort the array items by the name of the product.
As far as I know, I am on the right track of doing this, but I am not for sure.
/tmp/21938/Fish.java:8: cannot find symbol
symbol : class inventory
location: class Fish
new inventory (4);
^
/tmp/21938/Inventory.java:27: cannot find symbol
symbol : method getNumber()
location: class Product[]
System.out.println("Number: " + product.getNumber());
^
/tmp/21938/Inventory.java:28: cannot find symbol
symbol : method getName()
location: class Product[]
System.out.println("Name: " + product.getName());
^
/tmp/21938/Inventory.java:29: cannot find symbol
symbol : method getQuantity()
location: class Product[]
System.out.println("Quantity: " + product.getQuantity());
^
/tmp/21938/Inventory.java:30: cannot find symbol
symbol : method getPrice()
location: class Product[]
System.out.println("Price: " + product.getPrice());
^
/tmp/21938/Inventory.java:32: cannot find symbol
symbol : method getQuantity()
location: class Product[]
product.getQuantity() * product.getPrice());
^
/tmp/21938/Inventory.java:32: cannot find symbol
symbol : method getPrice()
location: class Product[]
product.getQuantity() * product.getPrice());
^
/tmp/21938/Inventory.java:35: operator < cannot be applied to Product[],int
for ( int MAXIUM_ITEMS = 4; product < product.length; product++ )
^
/tmp/21938/Inventory.java:35: operator ++ cannot be applied to Product[]
for ( int MAXIUM_ITEMS = 4; product < product.length; product++ )
^
/tmp/21938/Inventory.java:37: operator + cannot be applied to Product[],int
product + 1, product[product.getName()] );
^
/tmp/21938/Inventory.java:37: cannot find symbol
symbol : method getName()
location: class Product[]
product + 1, product[product.getName()] );
^
/tmp/21938/Inventory.java:39: cannot find symbol
symbol : variable total
location: class Inventory
total = (inventory[ 0 ].getValueOfStock() +
^
/tmp/21938/Inventory.java:39: cannot find symbol
symbol : variable inventory
location: class Inventory
total = (inventory[ 0 ].getValueOfStock() +
^
/tmp/21938/Inventory.java:40: cannot find symbol
symbol : variable inventory
location: class Inventory
inventory[ 1 ].getValueOfStock() +
^
/tmp/21938/Inventory.java:41: cannot find symbol
symbol : variable inventory
location: class Inventory
inventory[ 2 ].getValueOfStock() +
^
/tmp/21938/Inventory.java:42: cannot find symbol
symbol : variable inventory
location: class Inventory
inventory[ 3 ].getValueOfStock() +
^
/tmp/21938/Inventory.java:43: cannot find symbol
symbol : variable inventory
location: class Inventory
inventory[ 4 ].getValueOfStock());
^
/tmp/21938/Inventory.java:44: cannot find symbol
symbol : variable total
location: class Inventory
System.out.printf( "The total value of the inventory is: $%.2f\n\n", total );
^
18 errors
Here is all my codes: (Product.java compiles)
[/code]public class Inventory{
public static final int MAXIMUM_ITEMS = 4;
Product product[] = new Product[MAXIMUM_ITEMS];
public Inventory(){
buildInventory();
getInventory();
}
public void buildInventory() {
product[0] = new Product(1, "Bursa Trigger", 3, 39.99);
product[1] = new Product(2, "Clown Trigger", 1, 74.99);
product[2] = new Product(3, "Blueline Trigger", 2, 59.99);
product[3] = new Product(4, "Queen Trigger", 1, 99.99);
}
public void getInventory() {
for(int i = 0; i < product.length; i++) {
System.out.println("Number: " + product.getNumber());
System.out.println("Name: " + product.getName());
System.out.println("Quantity: " + product.getQuantity());
System.out.println("Price: " + product.getPrice());
System.out.println("Item Value: " +
product.getQuantity() * product.getPrice());
System.out.println();
for ( int MAXIUM_ITEMS = 4; product < product.length; product++ )
System.out.printf( "New Product %2d: %3d\n",
product + 1, product[product.getName()] );
{
total = (inventory[ 0 ].getValueOfStock() +
inventory[ 1 ].getValueOfStock() +
inventory[ 2 ].getValueOfStock() +
inventory[ 3 ].getValueOfStock() +
inventory[ 4 ].getValueOfStock());
System.out.printf( "The total value of the inventory is: $%.2f\n\n", total );
}
}
}
}
public class Product
{
private String name;
private int number;
private int units;
private double price;
public Product ( )
{
}
public Product ( String nameIn, int numberIn, int unitsIn, double priceIn, double valueIn )
{
setName (nameIn);
setNumber (numberIn);
setUnits (unitsIn);
setPrice (priceIn);
setValue (valueIn);
}
public void setName( String nameInput )
{
name = nameInput;
}
}
public void setNumber ( int numberInput )
{
[]number = numberInput;
}
public void setUnits ( int unitsInput )
{
units = unitsInput;
}
public void setPrice ( double priceInput )
{
price = priceInput;
}
public String getName ( )
{
return ( name);
}
public double getNumber ( )
{
return ( number );
}
public double getUnits ( )
{
return ( units );
}
public double getPrice ( )
{
return ( price );
}
public double stockValueInDollars()
{
return ( units * price );
}
public String toString()
{
String formatString = "Identification Number : %d\n";
formatString += "Product Name : %s\n";
formatString += "Units In Stock : %d\n";
formatString += "Unit Price : $%.2f\n";
formatString += "Stock Value : $%.2f\n\n";
return String.format ( name(),identificationNumber(), unitsInStock(),unitPriceInDollars(),stockValueInDo llars() );
}
}
import java.util.Arrays;
public class Fish{
public Fish() {}
public static void main( String args[] ) {
new inventory (4);
}
}[code]