Question: [c++] using this code, have the program sort and display the songs in alphabetical orde r within the sorted albums names using of the external

[c++] using this code, have the program sort and display the songs in alphabetical order within the sorted albums names using of the external file listed below. (you can make modifications to code as needed).

#include

#include

#include

#include

using namespace std;

struct album

{

string name;

string date;

string songs[28];

int count = 0;

album() { count = 0; }

};

int main()

{

album Albums[5];

string st;

int i = 0;

ifstream infile("input.txt");

//read in until end of file

while (!infile.eof())

{

getline(infile, Albums[i].name);

getline(infile, Albums[i].date);

Albums[i].count = 0;

cout << "Album Name: " << Albums[i].name << endl;

cout << "Alubum Year: " << Albums[i].date << endl;

getline(infile, st);

cout << "Songs in Album:" << endl;

// ignore the =

while (st[0] != '=' && !infile.eof())

{

Albums[i].songs[Albums[i].count++] = st;

cout << st << endl;

getline(infile, st);

}

cout << "===========================================" << endl << endl;

i++;

}

cout << "Total " << i << " records loaded" << endl;

for (int j = 0;j < i;j++)

{

for (int k = j + 1;k < i;k++)

{

if (Albums[j].name > Albums[k].name)

{

album temp = Albums[j];

Albums[j] = Albums[k];

Albums[k] = temp;

}

}

}

cout << "---------------------------------------- ";

cout << "---------------------------------------- ";

cout << "---------------------------------------- ";

cout << " Sort by album name and song name " << endl;

for (int j = 0;j < i;j++)

{

cout << "======================================== ";

cout << "Album Name: " << Albums[j].name << endl;

cout << "Alubum Year: " << Albums[j].date << endl;

cout << "Songs in Album:" << endl;

for (int k = 0;k < Albums[j].count;k++)

{

cout << Albums[j].songs[k] << endl;

}

}

infile.close();

system("PAUSE");

return 0;

}

----------------------------------------------------------

input.txt

Nat King Cole Sings George Shearing Plays

1962

1. September Song

2. Pick Yourself Up

3. I Got It Bad

4. Let There Be Love

5. Azure-Te

6. Lost April

7. A Beautiful Friendship

8. Fly Me To The Moon

9. Serenata

10. I'm Lost

11. There's A Lull In My Life

12. Don't Go

13. Everything Happens To Me

14. The Game Of Love

15. Guess I'll Go Back Home

=================================

The Christmas Song

1963

1. Christmas Song

2. Deck the Hall

3. O Come All Ye Faithful

4. God Rest Ye Merry Gentlemen

5. O Tannenbaum

6. O Little Town of Bethlehem

7. I Saw Three Ships

8. O Holy Night

9. Hark! The Herald Angels Sing

10. A Cradle in Bethlehem

11. Away in a Manger

12. Joy to the World

13. The First Noel

14. Caroling, Caroling

15. Silent Night

16. Buon Natale

17. All I Want for Christmas

18. The Happiest Christmas Tree

19. The Christmas Song

=================================

Nat King Cole Sings His Songs From Cat Ballou ...

1965

1. The Ballad Of Cat Ballou

2. Blue Gardenia

3. St LouisBlues

4. The Song Of Raintree County

5. In The Cool Of The Day

6. They Can't Make Her Cry

7. China Gate

8. Night Of The Quarter Moon

9. Never Let Me Go

10. Beale Street Blues

11. Haji Baba

=================================

The World Of Nat King Cole

2005

1. Smile

2. Straighten Up And Fly Right

3. Route 66

4. For Sentimental Reasons

5. Nature Boy

6. Too Young

7. Unforgettable

8. Walkin' My Baby Back Home

9. Orange Colored Sky

10. A Blossom Fell

11. Mona Lisa

12. Ramblin' Rose

13. Let There Be Love

14. L-O-V-E

15. When I Fall In Love

=================================

The Very Best Of Nat King Cole

2006

1. Stardust

2. Sweet Lorraine

3. Route 66

4. Straighten Up And Fly Right

5. For Sentimental Reasons

6. What'll I Do?

7. Morning Star

8. Penthouse Serenade

9. Candy

10. Walkin' My Baby Back Home

11. Unforgettable

12. Mona Lisa

13. Nature Boy

14. Somewhere Along The Way

15. Smile

16. A Blossom Fell

17. Can't I?

18. Let There Be Love

19. Almost Like Being In Love

20. Ballerina

21. I'm Gonna Sit Right Down

22. Let's Face The Music And Dance

23. Autumn Leaves

24. When I Fall In Love

25. That Sunday, That Summer

26. Looking Back

27. L-O-V-E

28. I Wish You Love

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!