SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 6 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 12 Dec 2017 My Price 10.00

data given is a list of albums, the file layout will contain

Album Sorter

Approximate Time To Complete: 1.5 Hours

 

You are tasked with writing a program that will sort entries by a specified column. The data given is a list of albums, the file layout will contain an album name, year, genre and artist on each line.

 

<album name,year genre,artist>

Example:

Dive,2011,Ambient,Tycho

 

File Example:

Epoch,2016,Electronic,Tycho
Farewell,2016,Chamber,Cicada
The Beatles,1968,Rock,The Beatles

 

Your program will have to interpret 3 commands and one command line argument:

DISPLAY
SORT <column> <ASC|DESC>
QUIT

 

The command line argment will be the filename containing the album list.

./albums albumlist.list

If a file has not been specified, the program should output:

No File Specified

and quit with return code 1.

 

If a file does not exist the program should output:

File Does Not Exist

and quit with return code 1.

 

The SORT command allows the user to specify the column they want the albums sorted by. The columns are within the range of [0,3], specifying column 0 will sort the albums by name. Specifying column 1 is will sort the album by year.

 

The DISPLAY command allows the user to show the current entries and their order. If the entries have not been sorted it will show their current order. It will list each entry similar to the command separated file by after each comma there is a space.

 

<album, year, genre, artist>

Example Output:

Dive, 2011, Electronic, Tycho
Portraits, 2015, Electronic, Maribou State
Mer De Noms, 2000, Hard Rock, A Perfect Circle

 

The QUIT command allows the user to quit the program and should trigger any cleaning up of memory that had been allocated over the life time of the program.

 

You have been provided with a small list to test your program with.

(assortment.list)

 

You are recommended to use the qsort() function to sort the albums and practice using function pointers (creating a comparator function) as well as using strtok() (or sscanf()) for parsing the data.

 

Assumptions/Clarifications:

* You can assume that there are only 4 attributes

* Maximum Line Length is 8192 characters (although we would encourage you to handle variable line length)

* If ASC or DESC has not been specified your program should sort ascending by default.

* You are just sorting by the column. (We assume the order is based on first read, previous sorts may affect subsequent order but if the entries are mapped the same way in the file, the output will be the same).

 

Examples:

Example 1:

./albums assortment.list

 

DISPLAY
Dive, 2011, Electronic, Tycho
Portraits, 2015, Electronic, Maribou State
Mer De Noms, 2000, Hard Rock, A Perfect Circle
Awake, 2014, Electronic, Tycho
Epoch, 2016, Electronic, Tycho
Farewell, 2016, Chamber, Cicada
The Beatles, 1968, Rock, The Beatles
Sines, 2014, Post-Metal, Jakob
QUIT

 

Example 2:

 

./albums assortment.list

 

SORT 1 ASC
DISPLAY
The Beatles, 1968, Rock, The Beatles
Mer De Noms, 2000, Hard Rock, A Perfect Circle
Dive, 2011, Electronic, Tycho
Sines, 2014, Post-Metal, Jakob
Awake, 2014, Electronic, Tycho
Portraits, 2015, Electronic, Maribou State
Farewell, 2016, Chamber, Cicada
Epoch, 2016, Electronic, Tycho
QUIT

 

Example 3:

./albums assortment.list

 

SORT 0 DESC
DISPLAY
The Beatles, 1968, Rock, The Beatles
Sines, 2014, Post-Metal, Jakob
Portraits, 2015, Electronic, Maribou State
Mer De Noms, 2000, Hard Rock, A Perfect Circle
Farewell, 2016, Chamber, Cicada
Epoch, 2016, Electronic, Tycho
Dive, 2011, Electronic, Tycho
Awake, 2014, Electronic, Tycho
QUIT

 

Example 4:

./albums assortment.list

 

SORT 3 ASC
DISPLAY
Mer De Noms, 2000, Hard Rock, A Perfect Circle
Farewell, 2016, Chamber, Cicada
Sines, 2014, Post-Metal, Jakob
Portraits, 2015, Electronic, Maribou State
The Beatles, 1968, Rock, The Beatles
Epoch, 2016, Electronic, Tycho
Awake, 2014, Electronic, Tycho
Dive, 2011, Electronic, Tycho
QUIT

 

Example 5:

./albums does_not_exist.list

 

File Does Not Exist

 

Example 6:

./albums

 

No File SpecifiedDive,2011,Electronic,Tycho
Portraits,2015,Electronic,Maribou State
Mer De Noms,2000,Hard Rock,A Perfect Circle
Awake,2014,Electronic,Tycho
Epoch,2016,Electronic,Tycho
Farewell,2016,Chamber,Cicada
The Beatles,1968,Rock,The Beatles
Sines,2014,Post-Metal,Jakob

Answers

(5)
Status NEW Posted 12 Dec 2017 08:12 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)