Reference Questions and Answers

Start Your Free Trial

Create a java class called product with three data elements: name, price peer unit and quantity . Accessors and Mutators methods and at least three Constructors. In Main Java application Call the product class to create at least three objects each with different constructor ,calculate the cost of each product object and the total price and print out the data about the product objects.

The contents of the Java file Product.java is given.

Expert Answers info

Borys Shumyatskiy eNotes educator | Certified Educator

calendarEducator since 2015

write1,096 answers

starTop subjects are Math and Science

The class is pretty straightforward: it is public, it contains three private members, three public constructors with different sets of parameters, three public accessors and three public mutators. The file for this class should be named Product.java (the same name as the class name).

One more public member that one can add is the method that multiplies price by quantity to get the cost of the product.

The rules of this site tells not to do entire assignment,...

(The entire section contains 198 words.)

Unlock This Answer Now