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

2yGooks catalog ks My litrary csci 136 home 518 Stacks Lab Using Favorite Song-D

ID: 3734200 • Letter: 2

Question

2yGooks catalog ks My litrary csci 136 home 518 Stacks Lab Using Favorite Song-Due 3/20 11 52pm 5.18 Stacks Lab Using Favorite Song - Due 3/20 11:59pm Create a Stack class that inhenits from your SinglyList or DoublyList class Note Your Singly ist or Doubly list class will need to be able to hold nodes that are of thé type Song Meaning objects of the type Song implements the following functions Push pushes item on the stack Pop pops the last itern off of the stack Use the code from the favorite Song assignment ·Push al the favorite songs onto the stack Push the following songs onto the stack Artist Solange Tale Don't Touch My Hair, Genre Soul, Duration 4.24 Artist Solange. Title "Cranes In the Sky. Genre Soul Duration: 3.24 Artist SZA. Title "Love Galor Genee RB, Duration 4.44 Pop all the last three songs off of the stack y518 1 Stacks Lab Using Favorite Song Due 3/20 11 59pm ACSNITY

Explanation / Answer

ANSWER:

#include<cstdio>

#include<iostream>

#include<string.h>

#include<cstdlib>

using namespace std;

struct song{

char name[100],genre[20];

   double duration;

   struct song *next;

};

class sll{

   struct song *head;

   public :

   void insert(char nam,char gen,double dura){

       song temp=(song )malloc(sizeof(struct song));

       strcpy(temp->name,nam);

       strcpy(temp->genre,gen);

       temp->duration=dura;

       temp->next=NULL;

       if(head==NULL)head=temp;

       else{

           temp->next=head;

           head=temp;

       }

   }

   void delt(){

       cout<<"-- Artist : "<<head->name<<"Genre : "<<head->genre<<" Duration : "<< head->duration <<" ";

       song *temp=head;

       head=head->next;

       delete(temp);

   }

};

class stack{

   sll sta;

   public :

   void push(){

       char song[100],genre[20];double duration;

       gets(song);

       gets(genre);

       cin>>duration;

       sta.insert(song,genre,duration);

   }

   void pop(){

       sta.delt();

   }

};

int main(){

   stack s1;

   s1.push(); //call push and pop as many times as u want.....

   s1.pop();

   return 0;

}

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