5 Replies - 27791 Views - Last Post: 18 February 2010 - 04:38 AM Rate Topic: -----

#1 Demtellme2program  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-November 06

Inventory Application

Posted 08 November 2006 - 02:40 PM

Please help. I have already finished my code. I just need help in compiling it. For some reason it will not compile. Please help.
// 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 InventoryPart1

{
   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


edit: added [code] tags ~ jayman9

Is This A Good Question/Topic? 0
  • +

Replies To: Inventory Application

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Inventory Application

Posted 08 November 2006 - 02:47 PM

In order for someone to help you, you will need to post all the error messages you are getting when you try to compile your program.
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Inventory Application

Posted 08 November 2006 - 02:49 PM

:) You may also have to be prepared for the fact that you may not have finished your code, especially if it will not compile. :)
Was This Post Helpful? 0
  • +
  • -

#4 shiva_kudi  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 22-October 06

Re: Inventory Application

Posted 08 November 2006 - 04:54 PM

Here is the modified code that iam sending as an attachment.
----------------------------------------------------------------------------
//Inventory.java 
//Program that displays the value of a product in inventory.


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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


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 InventoryPart1

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

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

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

		 System.out.println( "Enter the name of product or the word stop: " ); // prompt for input
		 myItem.setprodname(input.readLine());// 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
			 double d = Double.valueOf(input.readLine()).doubleValue();
			 myItem.setItemNum(d);// read item number

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

			// Enter Number of Items in Stock
			System.out.print("Enter number of Items in Stock:");
			myItem.setnuminstock(Double.valueOf(input.readLine()).doubleValue()); // 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(Double.valueOf(input.readLine()).doubleValue()); // read Item number
			}

			// Enter price of the Item
			System.out.print( "Enter the price of the item: " ); // prompt for input
			myItem.setprodprice(Double.valueOf(input.readLine()).doubleValue()); // 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(Double.valueOf(input.readLine()).doubleValue()); // read Item Price
			}

			System.out.println("The value of "+myItem.getprodname()+ " is $ "+myItem.calculateValue() ); // display the calculated inventory value

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

		} // end while

	  } // end method main

   } // end class InventoryPart1




sorry, i said attachment. But its not as attachement. Its the modified code that i sent in my previous reply.

edit: added [code] tags ~ jayman9
Was This Post Helpful? 0
  • +
  • -

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Inventory Application

Posted 08 November 2006 - 05:34 PM

Can you post the error message you are getting?

It will make it much easier to help you resolve the problem you are having.
Was This Post Helpful? 0
  • +
  • -

#6 Guest_paul*


Reputation:

Re: Inventory Application

Posted 18 February 2010 - 04:38 AM

how to run this program..
because my program in java is inventory system..
pls help me to resolve my problem..thank you.
heres my my email address. pauljohn_malapit@yahoo.com
Was This Post Helpful? 0

Page 1 of 1