Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ coding required. 6. There is a CD available for purchase that contains .jpeg

ID: 3792206 • Letter: C

Question

C++ coding required.

6. There is a CD available for purchase that contains .jpeg and gif images of music that is in the public domain. The CD includes a file consisting of lines contain- ing the names, then composers of that title, one per line. The name of the piece is first, then zero or more spaces then a dash character, then one or more spaces, then the composer's name. The composer name may be only the last name, an initial and one name, two names (first and last) or three names (first, middle, and last). There are a few tunes with "no author listed" as author. In the subsequent processing, "no author listed" should not be rearranged. Here is a veryabbreviated list of the titles and authors 1. Adagio "Moonlight" Sonata Ludwig Van Beethoven 2. An Alexis F.H. Hummel and J.N. Hummel 3. A La Bien Aimee Ben Schutt 4. At Sunset E. MacDowell 5. Angelus J. Massenet 6. Anitra's Dance Edward Grieg 7. Ase's Death Edward Grieg 8. Au Matin- Benj. Godard 37. The Dying Poet L. Gottschalk 38. Dead March G.F. Handel 39. Do They Think of Me At Home Chas. W. Glover 40. The Dearest Spot W.T. Wrighton 1. Evening Van Beethoven 2. Embarrassment Franz Abt 3. Erin is my Home no author listed 4. Ellen Bayne Stephen C. Foster 9. Alla Mazurka A. Nemerowsky 1. The Dying Volunteer A.E. Muse 2. Dolly Day Stephen C. Foster 3. Dolcy Jones Stephen C. Foster 4. Dickory, Dickory, Dock no author listed

Explanation / Answer

// Program that implements queue as a linked list
# include <iostream.h>
# include <conio.h>
class queue
{
   private :

       struct node
       {
           int data ;
           node *link ;
       } *front, *rear ;

   public :

       queue( ) ;
       void addq ( int item ) ;
       int delq( ) ;
       ~queue( ) ;
} ;

// initialises data member
queue :: queue( )
{
   front = rear = NULL ;
}

// adds an element to the queue
void queue :: addq ( int item )
{
   node *temp ;

   temp = new node ;
   if ( temp == NULL )
       cout << " Queue is full" ;

   temp -> data = item ;
   temp -> link = NULL ;

   if ( front == NULL )
   {
       rear = front = temp ;
       return ;
   }

   rear -> link = temp ;
   rear = rear -> link ;
}

// removes an element from the queue
int queue :: delq( )
{
   if ( front == NULL )
   {
       cout << " Queue is empty" ;
       return NULL ;
   }

   node *temp ;
   int item ;

   item = front -> data ;
   temp = front ;
   front = front -> link ;
   delete temp ;
   return item ;
}

// deallocates memory
queue :: ~queue( )
{
   if ( front == NULL )
       return ;
   node *temp ;
   while ( front != NULL )
   {
       temp = front ;
       front = front -> link ;
       delete temp ;
   }
}

void main( )
{
   queue a ;
   clrscr();
   a.addq ( 34 ) ;
   a.addq ( 46 ) ;
   a.addq ( 23 ) ;
   a.addq ( 29 ) ;
   a.addq ( 15 ) ;
   a.addq ( 33 ) ;
   a.addq ( 28 ) ;

   int i = a.delq( ) ;
   cout << " Item extracted: " << i ;

   i = a.delq( ) ;
   cout << " Item extracted: " << i ;

   i = a.delq( ) ;
   cout << " Item extracted: " << i ;
   getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote