Question: Implement a Shopping Cart program in Python. The program should allow users to add products to their shopping cart, remove products, update quantities, view the

Implement a Shopping Cart program in Python. The program should allow users to add products to their shopping cart, remove products, update quantities, view the list of items, set a tax rate, and calculate the total cost and tax. The program should be menu-driven and use variables, assignments, data types, conditional statements, classes, loops, and lists.
Requirements:
Product Class: Create a Product class to represent individual products. Each product should have the following attributes:
Name
Price per unit
Quantity
ShoppingCart Class: Create a ShoppingCart class to manage the shopping cart. This class should have the following functionalities:
Add a product to the cart.
Remove a product from the cart by name.
Update the quantity of a product in the cart.
Calculate the subtotal (sum of product prices * quantities).
Set and store the tax rate for the cart.
Calculate the total tax (subtotal * tax rate).
Calculate the total cost (subtotal + total tax).
Display the list of products in the cart with their names, prices, and quantities.
Menu-Driven Interface: Implement a menu-driven interface that allows users to perform the following actions:
Add a product to the cart (enter name, price, and quantity).
Remove a product from the cart by entering its name.
Update the quantity of a product in the cart (enter the name and new quantity).
Display all items in the cart.
Show the total cost of items in the cart.
Set the tax rate (prompt the user to enter the tax rate as a decimal, e.g.,0.08 for 8% tax).
Show the total tax amount.
Quit the program.
Unit Test: Write four new unit tests to verify the functionality of your ShoppingCart class. Test cases should cover adding, removing, updating products, and calculating totals. Your code should also pass the attached Unit Tests.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!