Hello,

Can anybody please help me figure out what I am missing here?

I need to to create an inventory program that holds multiple items. In addition, I also have to add the manufacturer and a 5% restock fee. The inventory also calculates the total value of the entire inventory. I would really appreciate any help...

I am getting one error but when I tried to remove this line, it gave me more errors.

InventoryProgramPart3.java:174: illegal start of expression
public double calculateInventory(product[])
^

Here is my entire code:

class product
{
     public int itemNumber;
     public String itemName;
     public int units;
     public double unitPrice;


     public void setItemNumber( int itemNumber )
     {
          this.itemNumber = itemNumber;
     }

     public int getItemNumber()
     {
          return itemNumber;
     }

     public void setItemName( String itemName )
     {
          this.itemName = itemName;
     }

     public String getItemName()
     {
          return itemName;
     }

     public void setUnits( int units )
 	{
          this.units = units;
     }

     public int getUnits()
     {
          return units;
     }


     public void setUnitPrice( double unitPrice )
     {
          this.unitPrice = unitPrice;
     }

     public double getUnitPrice()
     {
          return unitPrice;
     }

     // calculate supplies inventory value
     public double calculateValue()
     {
          return units * unitPrice;
     } // end method inventory value

    // initialize constructor
     product( int itemNumber, String itemName, int units, double unitPrice )
     {
		 itemNumber = itemNumber;
		 itemName = itemName;
		 units = units;
		 unitPrice = unitPrice;
	 } // end constructor


    // display inventory
     public void displayInventory()
     {
          System.out.println(); // outputs blank line

          System.out.println( "Product Number:  "+itemNumber );
          System.out.println( "Product Name:  "+itemName );
          System.out.println( "Quantity Available:  "+ units );
          System.out.printf( "Unit Price:  $%.2f", unitPrice );

          manufacturer product = new manufacturer
               ( "Corporate Express" );

          System.out.println( "\nManufacturer:  "+ product.getManufacturer() );

          // value() method and display the value
          System.out.printf( itemName +  "\nInventory value" + "is = $%.2f\n",
               calculateValue() );

    } // end display inventory

} // end class product

class manufacturer extends product
{
     // holds the supplies manufacturer
     private String suppliesManufacturer;

     // initialize constructor
     manufacturer( int itemNumber, String itemName, int units,
          double unitPrice, String manufacturer )
     {
          super( itemNumber, itemName, units, unitPrice );
          productManufacturer = manufacturer;
     } // end constructor

     // set product manufacturer
     public void setManufacturer( String manufacturer )
     {
          this.productManufacturer = manufacturer;
     } // end method

     // return product manufacturer
     public String getManufacturer()
     {
         return productManufacturer;
     } // end method

     // add 5% restocking fee
     public double calculateValue()
     {
          return super.calculateValue() * 1.05;
     } // end method

     // calculate restock fee
     public double calculateRestockFee()
     {
          return super.calculateValue() * .05;
     } //end method

     // String format
     public String toString()
     {
          String formatString = "Manufacturer:  %s";
          formatString += "Restock Fee:  $%.2f";
          formatString = String.format( formatString, productManufacturer,
               super.calculateValue() * 0.05 );
          return( formatString + super.toString() );
     }

     // display inventory
     public void displayInventory()
     {
          super.displayInventory();
          System.out.println( toString() );

          // Display total value plus reStock fee
          System.out.printf(itemName+  "\nInventory value" +" is: $%.2f\n",
               calculateRestockingFee() );

     } // end method display inventory

} // end class manufacturer

public class InventoryProgramPart3
{

	     // begin main method
	     public static void main(String args[] )
	     {
	       	  // create array for products
	          product product[] = new product[5];

	          product highlighter = new product( 35000, "Highlighter", 24, 5.75 );
	          product yellowPad = new product( 35001, "Yellow Pad", 20, 7.99 );
	          product pencil = new product( 35002, "Pencil", 12, 3.25 );
	          product scissors = new product( 35003, "Scissors", 6, 4.35 );
	          product manilaFolder = new product( 35004, "Manila Folder", 36, 6.50 );

					for (int i = 0; i < product.length; i++ )
					{
						System.out.println( "Product Number: /t" + product[i].getItemName());
					}

					// call calculateInventory method
					public static double calculateInventory(product[])
					{
						double sum = 0;

	 		   	      for ( int i = 0; i < product.length; counter++)
	 		   	      {
						  sum += product.getUnitPrice();
					  }
					  	return sum;
					}

	  		System.out.printf( "\nTotal inventory value: $%.2f\n", product );



	     } // end method main

 } // end class InventoryProgramPart3

// call calculateInventory method
public static double calculateInventory(product[])

this is not how you "call" a method, this is a method definition.

This article has been dead for over six months. Start a new discussion instead.