I am learning to write java programs but I really am not any good. My programs run but with a whole bunch of glitches. I have to write a java application that is like an inventory program. It has to have a product class obviously but it needs to hold an item number, the name of the product, the number of units in stock and the price of each unit. It also needs to display the product number, product name, number of units in stock, price of each unit and the value of the inventory. I know that is the price of each multiplied by the number in stock. I just can't seem to do it and I am going to lose my mind. Can anyone help!

Sincerly,
java-clueless

//Fig.2.7:Inventory.java
//Inventory program

public class Inventory
{
	//main method begins execution of Java application
public static main(String args[] )
	{
		//create User to obtain input
		Scanner input = new Scanner( System.in );
public class Data video disk
{ 

	name1 String productName;
	int number1 String productNumber;
	int number2 String productStockAmount;
	int number3 String productPrice;
	int amount String stockValue;

} //end class Data video disk

	name1 // product name
	int  number1; // product number
	int number2; // product stock amount
	int number3; // product price
	int amount; // stock value; amount of number2 multiplied by number3
public class While
{
	System.out.print( “Enter product name: ” ); //prompt
	While ( name1 = input.nextName1(); read name from user)

	System.out.print( “Product number: ###-##-###: “ ); //prompt
	number1 = outputNextInt(); display number1)

	System.out.print( “Product stock amount: “ ); //prompt
	number2 = outputNextInt(); display product stock amount)

	System.out.print( “Product price: $##.##: “ ); //prompt
	number3 = outputNextInt(); display product price)

	amount = number2 x number3; // multiply numbers
	System.out.print( “Stock value is $d/n “ , amount); display amount)

} // end class While
} // end class Inventory

Have you done any programs before this one? You need to declare main() as

public static void main(String[] args){ 
        
}

You never ended your Inventory class, it needs its corresponding bracket. You need to import java.util.* to use Scanner.

You cannot declare a class like

public class Data video disk

It needs to be one word, as in

class DataVideoDisk{

Change the next block of code to actually declare your variables correctly. You cannot declare an int and String on the same line. Don't forget the semi-colons and make sure to actually give name1 a type.

//every line needs work
        name1 String productName;
	int number1 String productNumber;
	int number2 String productStockAmount;
	int number3 String productPrice;
	int amount String stockValue;

The code above is duplicated right below. You can't use While as a class name, think of something else. You cannot use 'x' as multiplication, it has to be '*'. Start fixing those errors and try to learn the Java syntax because most of your errors were syntax errors.

Thanks a million, I am just learning and I apparently don't need to be in this class. It is too hard for me, I understand how to write programs for the most part just can't grab ahold of java for dome reason.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.