Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

********WRITTEN IN C++. PLEASE TEST YOUR CODE BEFORE SUBMITTING IT AS IT SHOULD MEET THE REQUIREMENTS STATED IN THE INSTRUCTIONS. ********* ******BELOW IS WHAT IS

********WRITTEN IN C++. PLEASE TEST YOUR CODE BEFORE SUBMITTING IT AS IT SHOULD MEET THE REQUIREMENTS STATED IN THE INSTRUCTIONS. *********

image text in transcribed

image text in transcribed

******BELOW IS WHAT IS IN THE LIBRARY.TXT FILE******

image text in transcribed

BELOW IS HOW THE OUTPUT SHOULD LOOK

image text in transcribed

Problem: Write a C++ program that will allow a user to query a digital library of music. The music library will contain the following information for each song: id (sequence of numbers and/or letters, without spaces) title (may contain spaces in it) artist (may contain spaces in it) size (in Megabytes, could have fractional parts) plays (number of times the song has been played, a whole number) rating (a value between 1 and 5, the number of stars in the rating, a whole number) Note: Your program should be able to store up to 100 different songs. You may assume that the ids will be unique (you do not need to check for this). The program should first read the data from a text file named "library.txt". This file will contain data for each song in the library in the order listed above. The id, title, and artist will each be on a separate line. The size, plays, and rating will be on the same line. See the sample file on the class website. Then, it should offer the user a menu with the following options: 1. Display Songs sorted by title 2. Display Songs sorted by rating 3. Lookup title and artist by ID 4. Lookup ID by title and artist 5. Quit the Program The program should perform the selected operation and then re-display the menu. For the Display operations, display the information for each song on a separate line The values should line up in columns (use setw). The title and artist should be left justified, the remaining data should be right justified. Headers for the table are optional. For the Lookup operations, label the output values. If the product is not found, display an appropriate message Do not change the menu numbers associated with the operations. Additional Requirements: .This program must be done in a Linux or Unix environment, using a command line compiler like g++. Do not use codeblocks, eclipse, or Xcode to compile. Your program must compile and run, otherwise you will receive a score of 0. The program must be modular (use top-down design), with significant work done by functions. Each function should perform a single, well-defined task. Use incremental development! Implement one feature at a time!! .Use a partially filled array of structures to store the library: Use a counter variable to count the number of products that are read in from the file, and use this value as the size of the array for the search and sort functions. See Pr5-22.cpp in the Assign2 provided code on TRACS Resources Your program should work for an input file with any number of songs up to 100. Use fin>>s getline(fin, str); to input a string on a given line, including spaces, from an input file fin into a string variable str. This also works for cin For option 2. Display Songs sorted by rating, if multiple songs have the same rating, it does not matter which one is listed first (or second...) within that group. Also sort in descending order: from 5 down to 1 You MUST use binary search for option 3. Lookup title and artist by ID. I recommend linear search for option 4. .You may use (and modify) the code from the book. See the Resources tool in TRACS. Please look at this code before you start implementing your program. I will put a sample input file on the class website (library.txt) and the console output from running my solution on that file (output2.txt) A201 My Heart Will Go On Celine Dion 5.4 9 5 B331 Happy Pharrell Williams 3.9 15 4 D210 Let It Go Idina Menzel 4.8 99 5 A122 You've Got a Friend in Me Randy Newman 4.2 6 2 Henu 1. Display Songs sorted by title 2. Display Songs sorted by rating 3. Lookup title and artist by ID 4. Lookup ID by title and artist 5. Quit the Program Enter your choice: 1 Happy Let It Go My Heart Will Go On You've Got a Friend in Me Randy Newman Pharrel1 nilliams Idina Henze.l Celine Dion 3.9 LB 4.8 HB 5.4 HE 4.2 LB Menu 1. Display Songs sorted by title 2. Display songs sorted by rating 3. Lookup title and artist by ID 4. Lookup ID by title and artist 5. Quit the Program Enter your choice: 2 Let It Go My Heart Will Go On Happy You' ve Got a Friend in Me Randy Newman Idina Menzel Celine Dion 4.8 HD L1B 3.9 MB ME Menu 1. Display Songs sorted by title 2. Display Songs sorted by rating 3. Lookup title and artist by ID 4. Lookup ID by title and artist 5. Quit the Progran Enter your choice: 4 Enter the title: HappY Enter the artist: Pharrell William;s The ID of Happy by Pharrell williams is B331 Menu 1. Display Songs sorted by title 2. Display Songs sorted by rating 3. Lookup title and artist by ID 4. Lookup ID by title and artist 5. Quit the Program Enter your choice: 3 Enter the id of the song: B331 The song with ID B331 is: Happy by Pharrell williams Menu 1. Display Songs sorted by title 2. Display Songs sorted by rating 3. Lookup title and artist by ID 4. Lookup ID by title and artist 5. Quit the Program Enter your choice: 3 Enter the id of the song: C123

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago