The total cost of a group of items at a grocery store is based on the sum of the individual product prices and the tax (which is 5.75%). Products that are considered “necessities” are not taxed, whereas products that are considered “luxuries” are. The Product class is abstract, and it has a method called getTotalPrice. Your task is to create two subclasses of Product: NecessaryProduct and LuxuryProduct and implement the getTotalPrice method in each of these classes appropriately. Then modify the driver program to instantiate four products (two necessary and two luxury) and store them in the product array, print out each item in the array, and display the total cost of the items. You should not make any changes at all to Product.java, and you should only add to ShoppingTripStartingCode.java. Do not change any code that is already present Example (Cheese and bread are necessities and soda and candy are luxuries) Cheese $1.50 Soda $3.50 Bread $2.25 Candy $2.00 The total cost is $9.57 The computation is 1.50 + (3.50 * 1.0575) + 2.25 + (2.00 * 1.0575) = 9.57. Note that the price displayed next to each product is the price without tax.
The total cost of a group of items at a grocery store is based on the sum of the individual product prices and the tax (which is 5.75%). Products that are considered “necessities” are not taxed, whereas products that are considered “luxuries” are.
The Product class is abstract, and it has a method called getTotalPrice. Your task is to create two subclasses of Product: NecessaryProduct and LuxuryProduct and implement the getTotalPrice method in each of these classes appropriately. Then modify the driver program to instantiate four products (two necessary and two luxury) and store them in the product array, print out each item in the array, and display the total cost of the items.
You should not make any changes at all to Product.java, and you should only add to ShoppingTripStartingCode.java. Do not change any code that is already present
Example
(Cheese and bread are necessities and soda and candy are luxuries)
Cheese $1.50
Soda $3.50
Bread $2.25
Candy $2.00
The total cost is $9.57
The computation is 1.50 + (3.50 * 1.0575) + 2.25 + (2.00 * 1.0575) = 9.57. Note that
the price displayed next to each product is the price without tax.

![J Product.java
J Shopping TripStartingCode.java X
> AppData > Local > Temp > Temp2_Shopping Trip Starting Code.zip > Shopping Trip Starting Code > J Shopping TripStart
public class Shopping TripStartingCode {
1
2
CEEEEEEEEE
10
11
12
13
14
15
16
19
}
Run | Debug
public static void main(String[] args) {
}
Product[] products = new Product [4];
// TODO create two necessary and two luxury products and add them to
// the products array
double total = 0;
for (Product p products) {
}
// TODO print out each product
total += p.getTotalPrice();
// TODO display the total cost, rounded to the nearest cent](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9f63eb48-6b00-489b-a1fe-59380870ec9c%2Feaefb632-490e-4518-81b0-7ea90efac771%2Fjmuweui_processed.png&w=3840&q=75)

Step by step
Solved in 3 steps









