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

In C++. I\'m having particular trouble with this C++ problem. In this program, t

ID: 640212 • Letter: I

Question

In C++. I'm having particular trouble with this C++ problem. In this program, the menu is to pop up, asking the user to select a movie genre from the list (which is read into an array from a text file). From this choice, the user is shown a movie listed from another text file (read into another array). It sounds simple, but I'm having much difficulty in making things work. Here's what I've done. PLEASE HELP!

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

using namespace std;

int menu(string*,int)
{
   char ch;
   cout<<"Enter your choice:"<<endl;
   cout<<"(R)ecommend Movie"<<endl;
   cout<<"or"<<endl;
   cout<<"(Q)uit"<<endl;
   cout<<"CHOICE: "<<endl;
   cin>>ch;

   switch(ch)
       {
           case 'r':
           case 'R':loadGenres(int*);
                   nextMenu();  
                   break;
           case 'q':
           case 'Q':cout<<"Thank you for using our recommendations. Enjoy your movie."<<endl;
                   system("PAUSE");
                   return 0;
           default: cout<<"Invalid Entry. Please enter a valid option."<<endl;
                   break;
       }

}

void nextMenu()
{
   int movieSelection;
   cout<<"Here are the genres to choose from: "<<endl
   for (int j=0;j<50;j++)
   {
       cout<<j<<". "<<genresList[j]<<endl;
   }

   cout<<"Please enter your selection, or enter -1 to end"<<endl;
   cin>>movieSelection;
   while (movieSelection!=-1)
   {
       cout<<"You entered "<<movieSelection<<". "<<endl;
       string* searchMovie(string* pMovies, int nMovies, string genre, int *returned count);
   }
   if (movieSelection==-1)
   {
       return;
   }
}

string* loadGenres(int*)
{
   string genresList[50];
   ifstream inputFile;
   inputFile.open("genres.txt");
   for (int z=0; z<50; z++)
   {
       inputFile >> genresList[50];
   }
  
   inputFile.close();
   loadMovies();
}

string* loadMovies(int*)
{
  
   string moviesList[12000];
   ifstream inputFile;
   inputFile.open("movies.txt");
   for (int y=0; y<50; y++)
   {
       inputFile >> moviesList[12000];
   }
   inputFile.close();
   sortData();
}


void sortData(string*, int)
{
bool swap;
   int temp,array,size;
   do
   {
       swap=false;
       for (int count=0; count<(size-1);count++)
       {
           temp=array[count];
           array[count]=array[count+1];
           array[count+1]=temp;
           swap=true;
       }
   }
   while (swap);
}

string* searchMovie(string* pMovies, int nMovies, string genre, int *returned count)
{
   string g = "one";
string h = "one ";

string tmpG = g;
tmpG.resize(h.size(), ' ');

if (tmpG == h) {
cout << "4. Same (RIGHT) ";
} else {
cout << "4. Different (WRONG) ";
}
   srand(time(0));

}

string selectMovie()
{
  
   cout<<"We recommend the following movies: "<<endl;

}

main()

{

   cout<<"Movie Recommendation Selector"<<endl;
   cout<<" "<<endl;
   menu();
  
}

Explanation / Answer

void which_movies_to_view(movie_record movies[])
{
    int viewchoice;
    int genrechoice;

    do
    {
        cout<< "View all movies or by genre (press 1 for view all or 2 for by genre or 3 for exit: "<< endl;
        cin>> viewchoice;
  
        if (viewchoice == 1)
         {
            cout<< "These are all the movies available currently: "<< endl;
            cout << movies[0].title << endl;
           cout << movies[1].title << endl;
           cout << movies[2].title << endl;
           cout << movies[3].title << endl;
           cout << movies[4].title << endl;
       }
  
        else if(viewchoice == 2)
        {
           do
           {
            cout<< "Which genre do you want to view: kids (1),family (2), comedy (3), thriller (4), exit (5): "<< endl;
          
           cin>> genrechoice;
           cout << endl;
               
          
               if(genrechoice == 1)
                 {
                     cout << movies[0].title << endl;
                 }
                else if (genrechoice == 2)
                {
                     cout << movies[2].title << endl;
                }
                else if (genrechoice == 3)
                {
                     cout << movies[1].title << endl << movies[4].title << endl;
                }
                else if (genrechoice == 4)
                {
                      cout << movies[3].title << endl;
                }
             
      
           }while(genrechoice != 5);
      
        }
  

    }while(viewchoice != 3);


}

// this function should display the titles of the movies dependant one
// how user answer to view all or by genre in the function above.
void get_movies(movie_record movies[])
{

   int userchoice;

   do{
  
    cout<< "Please choose a movie to view (1 - 5) exit(6): "<< endl;
    cin>>userchoice;
  
    if(userchoice == 1)
    {
        cout << movies[0].title << endl;
     
    }
     if(userchoice == 2)
    {
        cout << movies[1].title << endl;
  
    }
     if(userchoice == 3)
    {
        cout << movies[2].title << endl;
   
    }
     if(userchoice == 4)
    {
        cout << movies[3].title << endl;
  
    }
     if(userchoice == 5)
    {
        cout << movies[4].title << endl;

    }

   }while(userchoice != 6);

}

//ask user which movies he wants to view, ask if they want to view all or by genre
void which_movies_to_view(movie_record movies[])
{
    int viewchoice;
    int genrechoice;

    do
    {
        cout<< "View all movies or by genre (press 1 for view all or 2 for by genre or 3 for exit: "<< endl;
        cin>> viewchoice;
  
        if (viewchoice == 1)
         {
            cout<< "These are all the movies available currently: "<< endl;
            for(int i=0;i<NUM_MOVIES;i++)
           {
               get_movies(movies,i+1);
           }
       }
  
        else if(viewchoice == 2)
        {
           do
           {
            cout<< "Which genre do you want to view: kids (1),family (2), comedy (3), thriller (4), exit (5): "<< endl;
          
           cin>> genrechoice;
           cout << endl;
               
          
               // Kids
               if(genrechoice == 1)
                 {
                       for(int i=0;i<NUM_MOVIES;i++)
                       {
                       if(movies[i].genre == "Kids")
                            get_movies(movies,i+1);
                       }
                 }

                // Familly
                else if (genrechoice == 2)
                {
                      for(int i=0;i<NUM_MOVIES;i++)
                       {
                       if(movies[i].genre == "Family")
                            get_movies(movies,i+1);
                       }
                }

               // Comedy
                else if (genrechoice == 3)
                {
                       for(int i=0;i<NUM_MOVIES;i++)
                       {
                       if(movies[i].genre == "Comedy")
                            get_movies(movies,i+1);
                       }
                }

               // Thriller
                else if (genrechoice == 4)
                {
                       for(int i=0;i<NUM_MOVIES;i++)
                       {
                       if(movies[i].genre == "Thriller")
                            get_movies(movies,i+1);
                       }
                }
             
      
           }while(genrechoice != 5);
      
        }
  

    }while(viewchoice != 3);


}

// this function should display the titles of the movies dependant one
// how user answer to view all or by genre in the function above.
void get_movies(movie_record movies[], int userchoice)
{

    if(userchoice == 1)
    {
        cout << movies[0].title << endl;
     
    }
     if(userchoice == 2)
    {
        cout << movies[1].title << endl;
  
    }
     if(userchoice == 3)
    {
        cout << movies[2].title << endl;
   
    }
     if(userchoice == 4)
    {
        cout << movies[3].title << endl;
  
    }
     if(userchoice == 5)
    {
        cout << movies[4].title << endl;

    }