Sample I/O: Welcome to shopping at Amazing! We sell books from American Novelists Please choose from the following options to get information on available books 1. Display all items 2. Add books to cart 3. Checkout 4. Quit Enter your option: 1 Title-Author-Year-Price Animal Farm- George Orwell- 1945- 19.99 The Great Gatsby- Scott Fitzgerald- 1934- 22.99 Jane Eyre- Charlotte Bronte- 1847- 27.99 Anna Karenina- Leo Tolstoy- 1877-

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Sample I/O:
Welcome to shopping at Amazing!
We sell books from American Novelists
Please choose from the following options to get information on available books
1. Display all items
2. Add books to cart
3. Checkout
4. Quit
Enter your option: 1
Title-Author-Year-Price
Animal Farm- George Orwell- 1945- 19.99
The Great Gatsby- Scott Fitzgerald- 1934- 22.99
Jane Eyre- Charlotte Bronte- 1847- 27.99
Anna Karenina- Leo Tolstoy- 1877- 21.99
Sanctuary- William Faulkner- 1931- 30.99
Adventures of Huckleberry Finn- Mark Twain- 1884- 28.99
1. Display all items
2. Add books to cart
3. Checkout
4. Quit
Enter your option: 2
Enter the title of the book to add: Animal Farm
Animal Farm added to cart
1. Display all items
2. Add books to cart
3. Checkout
4. Quit
Enter your option: 2
Enter the title of the book to add: Introduction to Programming
Introduction to Programming not found. Returning to main menu...
1. Display all items
2. Add books to cart
3. Checkout
4. Quit
Enter your option: 2
Enter the title of the book to add: Jane Eyre
Jane Eyre added to cart
1. Display all items
2. Add books to cart
3. Checkout
4. Quit
Enter your option: 3
Thanks for shopping
You purchased the following items:
Title-Author-Year-Price
Animal Farm- George Orwell- 1945- 19.99
Jane Eyre- Charlotte Bronte- 1847- 27.99
The total amount is: $ 47.98
1. Display all items
2. Add books to cart
3. Checkout
4. Quit
Enter your option: 4
The program is quitting

b. checkout(cart): Returns the total amount purchased using the user cart. This
function will be called when user chooses to checkout for option 3. cart contains
all the books user is purchasing. checkout function will get the price of an item
from the cart dictionary and returns the total amount. Hint: price of an item is
the last item from the cart's value list.
c. display_all_items(d): Takes any dictionary d and display all the items in the
dictionary. This function will be called for menu option 1 and option 3. Hint: How
to print a dictionary?
d. add books_to_cart(title, cart, items_dict): Add an item to cart from the
items_dict if title exists in the items_dict. For menu option 2, user will provide
the title. If title exists that book will be added to the cart. Upon successful
addition the function will return True otherwise returns False.
Transcribed Image Text:b. checkout(cart): Returns the total amount purchased using the user cart. This function will be called when user chooses to checkout for option 3. cart contains all the books user is purchasing. checkout function will get the price of an item from the cart dictionary and returns the total amount. Hint: price of an item is the last item from the cart's value list. c. display_all_items(d): Takes any dictionary d and display all the items in the dictionary. This function will be called for menu option 1 and option 3. Hint: How to print a dictionary? d. add books_to_cart(title, cart, items_dict): Add an item to cart from the items_dict if title exists in the items_dict. For menu option 2, user will provide the title. If title exists that book will be added to the cart. Upon successful addition the function will return True otherwise returns False.
Design solution: The template file contains a list of books sold on Amazing, each item in the list
contains the title, publication year, author and the prices. The program will generate an
items_dict where each key is the title of the book and the values will be a list of year, author
and price information. A customer will be presented with a main menu with 4 different options:
display all items, add an item to cart, checkout and exit the program. A customer can buy an
item by entering the title of the book. This program implements a dictionary called cart, where
each key is the title and the values are the list of year, author and price and We assume one
copy is added with each selection. The program keeps repeating by displaying the main menu
to user until user hits the quit button. If user hits the checkout option, the program will display
all the items in the cart and display the total amount purchased.
Implementation:
1. This program will require to use two .py files: utility and application files. utility file
contains all the helper functions. The application file contains the main functionality of
the program.
2. This program requires to implement two dictionaries: items_dict and cart. items_dict
will be populated from the given list of books at the beginning of the program. Each key
will be the title and the value will be a list of author, year and price. cart dictionary will
be a subset of items_dict that contains all the items user wants to purchase. The
structure will be same as items_dict.
3. The application file will contain a main function. main function implements the user
menu and calls all the functions from the utility file. Hint: How to import a function from
one file to another?
4. Utility file will contain the following function definitions. All these function call will be
made from application file.
a. build_dict(items): Returns items_dict from items list. items list is provided in the
template file. This function is defined in the utility file and will be called from the
application file at the beginning of the program.
Transcribed Image Text:Design solution: The template file contains a list of books sold on Amazing, each item in the list contains the title, publication year, author and the prices. The program will generate an items_dict where each key is the title of the book and the values will be a list of year, author and price information. A customer will be presented with a main menu with 4 different options: display all items, add an item to cart, checkout and exit the program. A customer can buy an item by entering the title of the book. This program implements a dictionary called cart, where each key is the title and the values are the list of year, author and price and We assume one copy is added with each selection. The program keeps repeating by displaying the main menu to user until user hits the quit button. If user hits the checkout option, the program will display all the items in the cart and display the total amount purchased. Implementation: 1. This program will require to use two .py files: utility and application files. utility file contains all the helper functions. The application file contains the main functionality of the program. 2. This program requires to implement two dictionaries: items_dict and cart. items_dict will be populated from the given list of books at the beginning of the program. Each key will be the title and the value will be a list of author, year and price. cart dictionary will be a subset of items_dict that contains all the items user wants to purchase. The structure will be same as items_dict. 3. The application file will contain a main function. main function implements the user menu and calls all the functions from the utility file. Hint: How to import a function from one file to another? 4. Utility file will contain the following function definitions. All these function call will be made from application file. a. build_dict(items): Returns items_dict from items list. items list is provided in the template file. This function is defined in the utility file and will be called from the application file at the beginning of the program.
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY