Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a subclass of Offering called Product. Make the Product constructor take a name and price. Implement the missing method. Submit just the Product class.

Make a subclass of Offering called Product. Make the Product constructor take a name and price. Implement the missing method. Submit just the Product class.

public abstract class Offering

{ private String name; public Offering(String n) { name = n; }

public abstract double getTotalCost();

public String toString()

{ return name + " costs $" + String.format("%.2f", getTotalCost()); } }

public class Demo1 { public static void main(String[] args)

{ Offering p1 = new Product("iPhone", 999);

Offering p2 = new Product("Movie ticket", 12);

Offering p3 = new Product("Backpack", 25);

Offering p4 = new Product("Toyota Corolla", 19000);

System.out.println(p1);

System.out.println(p2);

System.out.println(p3);

System.out.println(p4); } }

REQURED OUTPUT:

iPhone costs $999.00

Movie ticket costs $12.00

Backpack costs $25.00

Toyota Corolla costs $19000.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Assess three steps in the selection process.

Answered: 1 week ago

Question

Identify the steps in job analysis.

Answered: 1 week ago