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

Hi i need help writing this program in C++. YOU MUST USE A LINKED LIST CLASS. us

ID: 3766338 • Letter: H

Question

Hi i need help writing this program in C++.

YOU MUST USE A LINKED LIST CLASS.

using object oriented programing write a C++ program that stores and manipulates TV program information. Your program should read TV program information from a file called TVData.dat. The file contains the name of the show, Day show is on, time shown, and approximate number of viewers Your program should allow a user to do several things: Print the complete list of TV shows and all related data. Type in a TV show title and retrieve the day and time the show is on. Find TV shows with number of viewers greater than 20000 Add a show and all related data to the list Print the movie TV shows in order of popularity, greatest number of viewers to least. Please remeber to use a linked list class.

The contents of the TV.dat file are:
House of Cards
Wednesday
8:00pm
20278
Big Bang Theory
Tuesday
8:00pm
23574
Modern Family
Thursday
9:00pm
15546
The 100
Monday
10:00pm
13245
Scandal
Tuesday
9:00pm
16678

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>

using namespace std;

class TvShow
{
private:
   struct Show{
       string name;
       string day;
       string time;
       string views;
       Show *next;
   };
   Show *head;
public:
/*   TvShow Show(string n, string d, string t, double v)
   {
       name = n;
       day = d;
       time = t;
       views = v;
   }*/
   TvShow()
   {
       head = NULL;
   }
   void Prepend(string n, string d, string t, string v)
   {
       Show *newNode;
       Show *curr;

       newNode = new Show;
       newNode->name = n;
       newNode->day = d;
       newNode->time = t;
       newNode->views = v;
       newNode->next = NULL;

       newNode->next = head;
       head = newNode;
   }
   void Display()
   {
       Show *curr;
       curr = head;
       while (curr != NULL){
           cout << "Show: " << curr->name << endl;
           cout << "Air date: " << curr->day << endl;
           cout << "Time: " << curr->time << endl;
           cout << "Views: " << curr->views << endl;
           curr = curr->next;}
}
   void Find(string n)
   {
       Show *curr;
       bool found = false;

       curr = head;
       while (curr != NULL && (found == false)){
           if (n == curr->name){
               found = true;
               cout << "Show: " << curr->name << endl;
               cout << "Air Date: " << curr->day << endl;
               cout << "Time: " << curr->time << endl;}
           curr = curr->next;
}
       if (found == false){
           cout << "Not Found" << endl;}
   }
   void Add(string n, string d, string t, string v){
       Show *temp = new Show;

       if (!head){
           head = temp;
           return;}
       else{
           Show *last = head;
           while (temp->next != NULL)
           {
               last= last->next;
               last->next = temp;
           }
           Show *newNode = new Show;
           newNode->name = n;
           newNode->day = d;
           newNode->time = t;
           newNode->views = v;
           newNode->next = NULL;

       }
   }

};

int main()
{


   ifstream Tvfile;
   Tvfile.open("TvShow.dat");
   int size = 0;
   Tvfile >> size;

       TvShow *myshow;
       myshow = new TvShow[size];
       string tempname;
       string tempday;
       string temptime;
       string tempviews;

       for (int i = 0; i < size; i++){
           getline(Tvfile, tempname);
           Tvfile >> tempname;
           Tvfile >> temptime;
           Tvfile >> tempviews;
           myshow[i].Prepend(tempname, tempday, temptime, tempviews);
       }
       Tvfile.close();
       for (int i = 0; i < size; i++)
       {
           myshow[i].Display();
       }

   return 0;
}

Edit & Run:

Output:

House of Cards
Wednesday
8:00pm
20278
Big Bang Theory
Tuesday
8:00pm
23574
Modern Family
Thursday
9:00pm
15546
The 100
Monday
10:00pm
13245
Scandal
Tuesday
9:00pm
16678

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