Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this task i have to complete a python program for an on-line CD store. myprogram should create a list of records about CDs by

In this task i have to complete a python program for an on-line CD store. myprogram should create a list of records about CDs by reading the data from a file. The program should then display a menu that allows the user to sort the list by different attributes of the CDs or search for CDs based on these attributes until the user elects to quit. program should be decomposed into functions. I have specified some of the main function in this document, but you should use further functions when necessary. Note:I cannot use inbuilt functions for searching or sorting the list and have to write my own functions.

2 Function createDatabase

Input: None Output: Returns a list L containing the records in CD_Store.txt Description:

Function creates the database by reading from the file CD Store.txt. Each line in the file is a comma-separated record containing the

Title, Artist, Genre and Price of a CD. (Note: Title, Artist and Genre are strings, but Price is a number.) The database is stored as a list of lists. For example: If CD Store.txt contained: Gangnam Style,Psy,K Pop,8.28 The Piano Guys Live,The Piano Guys,Classical,19.99 Live on Earth,Cat Empire,Jazz,21.99 your program should store the database as the following list: [[Gangnam Style, Psy, K Pop, 8.28], [The Piano Guys Live, The Piano Guys, Classical, 19.99], [Live on Earth, Cat Empire, Jazz, 21.99]] Function DisplayMenu Input: none Output: Prints menu. Description: Program displays a menu with the following options:

1. Print List of CDs

2. Sort CDs by Title

3. Sort CDs by Artist

4. Sort CDs by Genre

5. Sort CDs by Price

6. Find All CDs by Title

7. Find All CDs by Artist

8. Find All CDs by Genre

9. Find All CDs with Price at Most X.

10. Quit Function PrintList

Function Print List Input: List of CD Output: Prints list in readable format. Description: Program prints the list of CDs in a format that is readable for users and includes a identifier what each field is

Function SortByTitle Input: List of CDs Output: Updates the list of CDs so that elements are sorted in ascending order by title.

Function FindByGenre

Input: a target string and a list of CDs Output: Prints all CDs in the list of CDs that have the genre target. Description: Program should print all elements in the list of CDs that have the genre given in target.Function FindByPrice Input: the price (a decimal number) and a list of CDs Output: Prints all CDs in the list of CDs that cost at most the given price.

Function FindByArtist Input: A target string and a list of CDs Output: Prints all CDs in the list of CDs that have target listed as the artist.

Function FindByArtist Input: a target string and a list of CDs Output:

Prints all CDs in the list of CDs that have target listed as the artist. Description: Program should print all elements in the list of CDs that have the artist that matches target

Function FindByPrice Input: the price (a decimal number) and a list of CDs Output: Prints all CDs in the list of CDs that cost at most the given price. Description: Program finds all CDs that cost at most the amount specified by pric

I would prefer if it the major components of the code could be described so that i can better understand the code.better.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions