i am a beginning student in java programming and I have to make an inventory application. I was able to compile my class but I cant get the sub class to compile and execute. can someone tell what to do.

public class Cars1
{
   private String productName;
   private String itemNumber;
   private int numberOfUnits;
   private double pricePerUnit;

   public Cars1( String productName, String itemNumber, int numberOfUnits, 
         double pricePerUnit )
   {
      productName = productName;
      itemNumber = itemNumber;
      numberOfUnits = numberOfUnits;
      pricePerUnit = pricePerUnit;
   }

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

   public String getProductName()
   {
      return productName;
   }

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

   public String getItemNumber()
   {
      return itemNumber;
   }

   public void setNumberOfUnits( int numberOfUnits )
   {
      numberOfUnits = numberOfUnits;
   }

   public int getNumberOfUnits()
   {
      return numberOfUnits;
   }

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

   public double getPricePerUnit()
   {
      return pricePerUnit;
   }

   public String toString()
   {
      return String.format( "%s %s\n%s: %s\n%s: %s\n%s: %.2f\n" ,
         getProductName(), getItemNumber(), getNumberOfUnits(), getPricePerUnit() );
   }

}

that is my super class or parent

public class CarInventory extends Cars1
{
   public static void main( String args )
   {
      CarInventory cars1 = new CarInventory(
         "Mercedes Benz", "1089", "2", 60000 );
      system.out.printf( "%s %s\n", "Product name is",
         cars1.getProductName() );
      System.out.printf( "%s %s\n", "Item number is",
         cars1.getItemNumber() );
      System.out.printf( "%s %s\n", "Number of Units",
         cars1.getNumberOfUnits() );
      System.out.printf( "%s %.2f\n", "Price per unit",
         cars1.getPricePerUnit() );

   }

}

this is my subclass, what is wrong here ,please help me someone.

I haven't used Java in many years, but is using main a problem?

public static void main( String args )

However, you appear to have a problem string string int double
but your pass string string string double

Correct. You have no entry point for your application (it can not run). The correct declaration is public static void main(String[] args). You're missing the brackets. Also, the code tags that you would have used had you read the forum rules.

:)

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.