mail@pastecode.io avatar
6 months ago
926 B
Design a C++ program to model a supermarket that maintains three different product sections: grocery, vegetables, and snacks. The program should utilize inheritance to create derived classes for each section, inheriting methods from a base class called "Product." Each product should have a name and a price.

Additionally, implement a "Customer" class that allows customers to add products to their cart and calculates their total bill. The program should prompt the user to input customer details and the products they want to purchase. If the total bill exceeds a certain amount of 5$, provide a discount of 10% to the customer.

Sample input output

Customer 1

Customer: John

Items Purchased:

Product: Rice

Price: $1.00


Product: Chips

Price: $2.00



Total Bill: $3.00


Customer 2

Customer: Jane

Items Purchased:

Product: Carrot

Price: $1.99


Product: Chips

Price: $2.99


Total Bill: $4.98