This discussion is archived
5 Replies Latest reply: Jul 1, 2007 11:35 AM by 807600 RSS

Java Inventory Array

807600 Newbie
Currently Being Moderated
I am trying to create a small program for class that allows the user to enter and store inventory items. I am supposed to update it now to store and display multiple items and add a subclass, but I can not get the first part to compile yet. On this part im getting an error message -
cannot find symbol
symbol : class Item
location : class WorkInventory

I am not understanding much of this java programming and am looking for any help I can find in getting a grasp of it.

The code for my program is as follows,
//WorkInventory.java
//Java Inventory Work Products

public class WorkInventory
{
   // main methods begins execution of java application
   public static void main( String args[])
   {
         Item myProduct = new Item();
 
         System.out.println("\n\nItem Name: "+myProduct.getItemName()); //display item name
                 System.out.println("Item Number: "+myProduct.getItemNumber()); //display item number
                 System.out.println("Quantity in Stock:"+myProduct.getStockQuantity()); //display quantity in stock
                 System.out.println("Item Price:$ "+myProduct.getItemPrice()); //display item price
                 System.out.println("Value of Inventory:$ "+myProduct.calculateInventoryValue()); //display total value of inventory for this item
 
         System.out.println("\n\nEnter item name or enter the word stop to quit:");//prompt
              //   myProduct.setItemName(input.next()); // read item name or stop
 
 
   } // end main method
}//end class WorkInventory
if anyone can offer me any advice it would be greatly appreciated
  • 1. Re: Java Inventory Array
    807600 Newbie
    Currently Being Moderated
    If you post the code for your Item class we will be able to see where you are going wrong.
  • 2. Re: Java Inventory Array
    807600 Newbie
    Currently Being Moderated
    See, I truly have no grasp of what I am doing here. This is all of what I have from following the text .
  • 3. Re: Java Inventory Array
    807600 Newbie
    Currently Being Moderated
    Well in that case I'd suggest starting right at the beginning

    http://java.sun.com/docs/books/tutorial/getStarted/index.html

    Otherwise you'll just end up confusing yourself more
  • 4. Re: Java Inventory Array
    807600 Newbie
    Currently Being Moderated
    Ok, this is about as basic as I can get and still understand what I am doing. The program is supposed to ask for item name, item number , quantity and price and then calculate the value of the item. After this, I am supposed to use an array to store and display multiple items, but I can not even get this far. I have started back at the very basics, where should I go from here?
    // InventoryX.java
    // Inventory Program
     import java.util.scanner;
    
     public class InventoryX 
    {
     //main method begins program
      
       public static void main( String args [] )
        {
          Scanner input = new Scanner(System.in);
    
       
                  System.out.println("Item Name:");//enter item name
                 itemName = input.nextString();
                  System.out.println("Item Number:");//enter item number
                    itemNumber= input.nextInt();
                  System.out.println("Quantity in Stock:");//quantity of item
                    itemQuantity = input.nextInt();
                  System.out.println("Item Price:");//price of item
                    itemPrice = input.nextDouble();
                  itemValue=itemQuantity * itemPrice
                  System.out.println("Value of Item in Stock is", 
    
    itemValue);//display value of stock for item
    
                 }// end main method
                   } end class InventoryX        
        
    Any help would be greatly appreciated as I have been unable to learn this from the reading assignments and have no hands on instructor to show me examples.
  • 5. Re: Java Inventory Array
    807600 Newbie
    Currently Being Moderated
    Ok, this is about as basic as I can get and still
    understand what I am doing.
    ...............
    I have started back at the very basics, where
    should I go from here?
    It's not enough to just start at the basics, you have to continue on. We can correct your mistakes here, but we can't teach you Java. You must teach yourself. Continue on in the tutorials and in your book til you get a grasp of basic Java. This is going to take a lot of work on your part, but with effort is not impossible. Good luck.