Question
Here's your first Python practice problem. You are writing a software program (T he Code ) for a Smart Shopping Cart that keeps track of
Here's your first Python practice problem. You are writing a software program (The Code) for a "Smart Shopping Cart" that keeps track of the number and total cost of items placed in it. This serves two purposes: maybe the shopper wants to go through the express lane and there's an item limit. And the shopper may have a grocery budget and must make sure not to overspend it.
The Startup:
The shopper must tell the Smart Cart the item limit (maximum number of items allowed in the cart) and their spending limit (maximum total cost of items allowed in the cart). Initially the total items and total cost both are zero.
The Loop:
The Smart Cart tells the shopper total items (how many items currently in the cart) and total cost (total cost of items currently in the cart).
If the shopper has reached their item limit or their spending limit, the Smart Cart should yell at them and exit.
The shopper tries to put an item in the cart.
NOTE: It would be nice if the Smart Cart would scan in items using bar codes...but we have to pretend that part by having the shopper enter the price of the item (s)he wants to put in the cart. If the user enters a cost of "0" this signals to the Smart Cart they are done shopping and the program should exit.
The Smart Cart must check to make sure adding the item will not go over budget. If so, it should yell at the shopper to put the item back and choose something cheaper. Otherwise, the Smart Cart should add one to the total items and add the item cost to the total cost.
The Evidence:
A SINGLE FILE that shows at least two successful test runs.
Test Run 1 should be a "happy shopping experience" where the user buys within their item and spending limits (must show at least three items being successfully added to the cart).
Test Run 2 should show an attempt to overspend or reaching the max number of items.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started