hi ive developed an inventory program but when i compile it keeps giving me an error message that ive tried solving but it doesnt work.the code looks like this:

// Inventory.java 
// Program that displays the value of a product in inventory.

import java.util.Scanner; // program uses class Scanner

class Product

{
   private double itemnum;     //  class variable that stores Item number
   private double prodprice; // class variable that stores tprice of the product
   private double numinstock;   // class variable that stores the number of product in stock
   private String prodname;  //class variable for the name of the product

   public Product() // Constructor for the Item
   {
      itemnum = 0.0;
      prodprice = 0.0;
      numinstock = 0.0;
   }
   public void setItemNum(double num)  // Method to set the Item number
   {
      itemnum = num;
   }
   public double getitemnumber()  // Method to get the Item number
   {
      return itemnum;
   }
   public void setprodprice(double prod)  // Method to set the Price of the product
   {
      prodprice = prod;
   }
   public double getprodprice()  // Method to get the Price of the product
   {
      return prodprice;
   }
   public void setnuminstock(double numstock)  // Method to set the Price of the product
   {
      numinstock = numstock;
   }
   public double getnuminstock()  // Method to get the Price of the product
   {
      return numinstock;
   }
   public void setprodname(String name)  // Method to set the name of the product
   {
      prodname = name;
   }
   public String getprodname()  // Method to get the name of the product
   {
      return prodname;
   }
   public double calculateValue()  // Method to calculate the weekly pay
   {
      return prodprice * numinstock;
   }

}//end class Product

public class Inventory

{
   public static void main( String args[] )
      {
         // create Scanner to obtain input from command window
         Scanner input = new Scanner( System.in );

         //Instantiate an Item object
         Item myItem = new Item();

         //Print out a screen title
              System.out.printf("Inventory Program\n\n");

         System.out.println( "Enter the name of product or the word stop: " ); // prompt for input
         myItem.setProdname(input.nextLine());// read item name or stop

         // while loop to repeat the entry of the item until stop is entered
         while (!(myItem.getProdname().equalsIgnoreCase("stop") ) )
         // start while
         {
            //Enter Item number
             System.out.print( "Enter the Item number: " ); // prompt for input
             myItem.setItemnum(input.nextDouble());// read item number

             // while loop to repeat the entry of the item number until a positive value is entered
             while (myItem.getItemnum()<=0.0)
             {
                System.out.println("Wrong Entry");
                System.out.println("Please enter a positive Item Number:");
                myItem.setItemnum(input.nextDouble()); // read Item number
            }

            // Enter Number of Items in Stock
            System.out.print("Enter number of Items in Stock:");
            myItem.setNuminstock(input.nextDouble()); // read Number of Items in Stock

            // while loop to repeat the entry of Items in stock until a positive value is entered
            while (myItem.getNuminstock()<=0.0)
            {
                System.out.println("Wrong Entry");
                System.out.println("Please enter a positive Number in Stock:");
                myItem.setNuminstock(input.nextDouble()); // read Item number
            }

            // Enter price of the Item
            System.out.print( "Enter the price of the item: " ); // prompt for input
            myItem.setProdprice(input.nextDouble()); // Read price of the product

            // while loop to repeat the entry of Items in stock until a positive value is entered
            while (myItem.getProdprice()<=0.0)
            {
                System.out.println("Wrong Entry");
                System.out.println("Please enter a positive Item Price:");
                myItem.setProdprice(input.nextDouble()); // read Item Price
            }

            System.out.printf("The value %s is $ %.2f\n\n\n", 
            myItem.getItemname();
            myItemname.calculatevalue() ; // display the calculated inventory value

            System.out.println("Enter the name of the product or the word stop:"); // prompt
            myItem.setItemname(input.next()); /// read item name or stop

        } // end while

      } // end method main

   } // end class InventoryPart1

Edited 3 Years Ago by Dani: Formatting fixed

What error message are you getting? After a quick glance through I think one of the more beneficial things you could do is separate your classes into separate files. You also appear to switch between myItem and myItemname when calling methods on your Item object.

Hello, milgo. You have in your program definition of a Product class. And as far as I understood, you was going to use it in Inventory class. But instead of that, you're creating an instance of Item:

//Instantiate an Item object
Item myItem = new Item();

By the way, there're a lot of small errors: you wrong typed a methods names (java is case-sensitive).

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