abstract class Product { //To return the price of this product abstract double price(); //To return the weight of this product abstract double weight(); //To return the price per ounce of this product abstract double pricePerOunce(); } class Carrot extends Product { double myWeight; Carrot( double myWeight ) { this.myWeight = myWeight; } //To return the price of this Carrot //new Carrot(3).price() -> 3.5 double price() { // ... this.myWeight ... return 3.5; } //To return the weight of this Carrot //new Carrot(3).weight() -> 3 double weight() { // ... this.myWeight ... return this.myWeight; } //new Carrot(3).pricePerOunce() -> 1.66666.... //To return the price per ounce of this Carrot double pricePerOunce() { // ... this.myWeight ... return this.price() / this.weight(); } } class Aspirin extends Product { int numPills; Aspirin( int num ) { this.numPills = num; } //To return the price of this Aspirin //new Aspirin(100).price() -> 5.95 double price() { // ... this.numPills ... return 5.95; } //To return the weight of this Aspirin //new Asprirn(100).weight() -> 5 double weight() { // ... this.numPills ... return this.numPills * .05; } double pricePerOunce() { // ... this.myWeight ... return this.price() / this.weight(); } }