Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a C program that produces a randomised set of songs from a longer list entered as input. Detailed Specification Input The program takes its

Create a C program that produces a randomised set of songs from a longer list entered as input.

image text in transcribedimage text in transcribed

Detailed Specification Input The program takes its input from a file specified as an argument to the program. If the file does not exists or is not readable, the program prints out an error message to this effect. If no file is specifed, the program searches in the current directory for a file called artistes+songs.txt. If no such file exists, the program prints a message "No file found." and then prompts the user to enter the artistes and songs information from the keyboard according to the specified format. The format of the file is as follows: Artiste name Song title***Song duration Song title***Song duration Song title***Song duration Artiste name Song title***Song duration Song title***Song duration Song title***Song duration Each song title comprises alphanumeric characters (letters, numbers and symbols) but does not contain the sub-string "Song duration" is in the form [m]m:ss, where [m]m denotes a one or two-digit number of minutes and ss denotes a two-digit number of seconds. For testing purposes, at least two artistes should have three or more songs each. Sort artistes and songs Your program should then sort the input by artiste name and then by song title and print it out in the following format: Sorted list of artistes and songs Artiste name o Song title***Song duration o Song title***Song duration o Song title***Song duration Artiste name o Song title***Song duration o Song title***Song duration o Song title***Song duration Produce randomised playlist The program should then generate a random playlist of the songs given as input, according to the following constraints: An artiste cannot have more than two songs in a row (so no "triple play", as the radio DJs might say); . An artiste cannot have more than three songs in total in the playlist; A song cannot appear twice in the playlist; The total playlist length should be as close as possible to one hour. Specifically, the last song must start on or before 59:59. The randomised playlist and the total time should be printed out in the following format: Randomised playlist Artiste name: "Song title" (Song duration) Artiste name: "Song title" (Song duration) Artiste name: "Song title" (Song duration) Total duration: Code requirements Use functions where possible; Break your code into independent modules; To sort the artistes and songs, use an algorithm other than exchange sort (bubble sort); A simple algorithm to use to shuffle the songs is the "Fisher-Yates shuffle" or "Knuth shuffle": see https://en.wikipedia for example; Your program should work for different lists of artistes and songs; Comment your code. Detailed Specification Input The program takes its input from a file specified as an argument to the program. If the file does not exists or is not readable, the program prints out an error message to this effect. If no file is specifed, the program searches in the current directory for a file called artistes+songs.txt. If no such file exists, the program prints a message "No file found." and then prompts the user to enter the artistes and songs information from the keyboard according to the specified format. The format of the file is as follows: Artiste name Song title***Song duration Song title***Song duration Song title***Song duration Artiste name Song title***Song duration Song title***Song duration Song title***Song duration Each song title comprises alphanumeric characters (letters, numbers and symbols) but does not contain the sub-string "Song duration" is in the form [m]m:ss, where [m]m denotes a one or two-digit number of minutes and ss denotes a two-digit number of seconds. For testing purposes, at least two artistes should have three or more songs each. Sort artistes and songs Your program should then sort the input by artiste name and then by song title and print it out in the following format: Sorted list of artistes and songs Artiste name o Song title***Song duration o Song title***Song duration o Song title***Song duration Artiste name o Song title***Song duration o Song title***Song duration o Song title***Song duration Produce randomised playlist The program should then generate a random playlist of the songs given as input, according to the following constraints: An artiste cannot have more than two songs in a row (so no "triple play", as the radio DJs might say); . An artiste cannot have more than three songs in total in the playlist; A song cannot appear twice in the playlist; The total playlist length should be as close as possible to one hour. Specifically, the last song must start on or before 59:59. The randomised playlist and the total time should be printed out in the following format: Randomised playlist Artiste name: "Song title" (Song duration) Artiste name: "Song title" (Song duration) Artiste name: "Song title" (Song duration) Total duration: Code requirements Use functions where possible; Break your code into independent modules; To sort the artistes and songs, use an algorithm other than exchange sort (bubble sort); A simple algorithm to use to shuffle the songs is the "Fisher-Yates shuffle" or "Knuth shuffle": see https://en.wikipedia for example; Your program should work for different lists of artistes and songs; Comment your code

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

What is organizational culture and how can leaders influence it?

Answered: 1 week ago