Hello I have an assignment that is due and am in need of some dire help. I would appreciate all the help that I can get. Please bear with me. I am new to Java and Daniweb. I have to create a java application that displays the product number, product name, amount in stock, price per unit, and the total amount of inventory. My application must include a class that hold the product number, product name, amount in stock, and the price per unit. By the way my product is cars. So far I have created two files (Cars.java and CarsInventory.java). I am not sure if this is even right. Am I going in the right direction? Could I have incorporated all of the information into one file? Next, I am not sure how to get both of the files to work together. In addition, when I run and compile each file separately I come up with the following error messages:
ERROR:
Cars.java: 19: missing return statement
} // end four-argument constructor
public class Cars
{
private int prodNumber; // product number
private String prodName; // product name
private int unitsTotal; // total units in stock
private double unitPrice; // price per unit
// initialize four-argument constructor
public int Cars( int number, String name, int total, double price)
{
prodNumber = number;
prodName = name;
setUnitsTotal (total); // validate and store total of cars
setUnitPrice (price); // validate and store price per car
} // end four-argument constructor
public void setProdNumber( int number )
{
prodNumber = number;
}
public int getProdNumber()
{
return prodNumber;
}
public void setProdName( String name)
{
prodName = name;
}
public String getProdName()
{
return prodName;
}
public void setUnitsTotal( int total )
{
unitsTotal = total;
}
public int getUnitsTotal()
{
return unitsTotal;
}
public void setUnitPrice( double price )
{
unitPrice = price;
}
public double getUnitPrice()
{
return unitPrice;
}
// calculate value of total inventory
public double inventory()
{
return unitsTotal * unitPrice;
} // end method value
} // end class Cars
ERROR:
CarsInventory.java: 9: cannot find symbol
symbol: class product
location: Class CarsInventory
Cars product = new product
public class CarsInventory
{
public static void main( String args [ ])
{
// instantiate cars object
Cars product = new Cars(
2479, "Dodge Viper GTS", 20, 65000);
// get car information
System.out.println(
"LNF New and Used Car Inventory Program");
System.out.printf( "%s %s\n", "Product Number",
product.getProdNumber() );
System.out.printf( "%s %s\n", "Product Name",
product.getProdName() );
System.out.printf( "%s %.2f\n", "Total Units in Stock",
product.getUnitsTotal() );
System.out.printf( "%s %.2f\n", "Price Per Unit",
product.getUnitPrice() );
} // end main method
} // end class CarsInventory