I am trying to get an inventory program can any one tell me what si wrong with this and how I can fix it, please!

import java.util.Scanner;

public class Cars1
{
   // main method begins java application
   public static void main( String args[] )
   {
      Scanner input = new Scanner( System.in );

      System.out.println( "Please enter Product name:" );

      String name = input.nextLine();

      private String productName;
      private String itemNumber;
      private int numberOfUnits;
      private double pricePerUnit;

      System.out.print( "item number: " );
      itemNumber = input.nextLine();

      System.out.print( "number of units: " );
      numberOfUnits = input.nextint();

      System.out.print( "What is unit price: " );

      System.out.printf( "price is $%f\n ",price );



    } // end main

    private String productName;
    private String itemNumber;
    private String numberOfUnits;
    private double pricePerUnit;

    public Cars( String product, String item, String number, 
      double price )
   {

      productName = product;
      itemNumber = item;
      numberOfUnits = number;
      setPricePerUnit( price );
   }

   public void setProductName( String product )
   {
      productName = product;
   }

   public String getProductName()
   {
      return productName;
   }

   public void setItemNumber( String item )
   {
      itemNumber = itemNumber;
   }

   public String getItemNumber()
   {
      return itemNumber;
   }

   public void setNumberOfUnits( String number )
   {
      numberOfUnits = number;
   }

   public String getNumberOfUnits()
   {
      return numberOfUnits;
   }

   public void setPricePerUnit( double price )
   {
      price = ( price < 0.0 ) ? 0.0 : price;
   }

   public double getPrice()
   {
      return pricePerUnit;
   }

   public String toString()
   {
      return String.format( "%s:  %s\n%s: %s\n%s: %s\n%s: %.2f",
         "cars", productName,
         "item number", itemNumber,
         "number of units", numberOfUnits,
         "price per unit", pricePerUnit );

   }

} // end class Cars1

since I posted my last msg, I have updated my code to this, please help!

import java.util.Scanner;

public class Cars1
{
   // main method begins java application
   public static void main( String args[] )
   {
      Scanner input = new Scanner( System.in );

      System.out.println( "Please enter Product name:" );

      String name = input.nextLine();

      private String productName;
      private String itemNumber;
      private int numberOfUnits;
      private double pricePerUnit;

      System.out.print( "item number: " );
      itemNumber = input.nextLine();

      System.out.print( "number of units: " );
      numberOfUnits = input.nextint();

      System.out.print( "What is unit price: " );

      System.out.printf( "price is $%f\n ",price );



    } // end main

    public String productName;
    public String itemNumber;
    public int numberOfUnits;
    public double pricePerUnit;

    public void Cars( String product, String item, int number, 
      double price )
   {

      productName = product;
      itemNumber = item;
      numberOfUnits = number;
      setPricePerUnit( price );
   }

   public void setProductName( String product )
   {
      productName = product;
   }

   public String getProductName()
   {
      return productName;
   }

   public void setItemNumber( String item )
   {
      itemNumber = itemNumber;
   }

   public String getItemNumber()
   {
      return itemNumber;
   }

   public void setNumberOfUnits( String number )
   {
      numberOfUnits = number;
   }

   public String getNumberOfUnits()
   {
      return numberOfUnits;
   }

   public void setPricePerUnit( double price )
   {
      price = ( price < 0.0 ) ? 0.0 : price;
   }

   public double getPrice()
   {
      return pricePerUnit;
   }

   public String toString()
   {
      return String.format( "%s:  %s\n%s: %s\n%s: %s\n%s: %.2f",
         "cars", productName,
         "item number", itemNumber,
         "number of units", numberOfUnits,
         "price per unit", pricePerUnit );

   }

} // end class Cars1

you didn't use code tags. read the stickies. all of them. completely.

Yes, definitely read the stickies regarding code tags and the rest of the rules. I explained code tags on two of your previous threads. Here, for the final time, is how to use them.

[code=JAVA] // Paste code here. Adds line numbers, preserves spacing, adds syntax highlighting.

[/code]

or

[code]

// Paste code here. Doesn't add line numbers, preserves spacing, doesn't add syntax highlighting.

[/code]

Repost with code tags. Make sure you use good indentation so the code is readable.

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.