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

Your assignment is to create a program that recommends movies from the movies.tx

ID: 3587823 • Letter: Y

Question

Your assignment is to create a program that recommends movies from the movies.txt file presented in the lecture 10 folder. You do not have to ask about every genre listed in that file, but select a minimum of 6 that have a fairly large number of movies. For instance, drama, comedy, romance, action, adventure, and thriller. You can ask preferences in any way you see fit, but the filtering must contain at least two parameters, for instance romance and comedy. After selecting the movie, ask the user if they are happy with the choice or would like you to choose another with the same criteria. Of course if no movie exists with those filters, give an appropriate message. You can do this any way you like as long as you meet these criteria. The result of the query should just be the movie title, not the other information in the data base. For instance you could say I suggest the movie Babe (1995). Extra credit if you randomize the choices so you do not get the same results every time you use the same filters. (use C++)

Explanation / Answer

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

using namespace std;

struct movie{
   string name;
   string genre;
};

int main(){

   struct movie list[1000];

   ifstream fin;
   int a,b;
   string str,str1;
   int count, count1;
   int d[100];
   int index;
   int found;
   int found1;
   string choice;

   for (int i = 0; i<100; i++){
       d[i] = -1;
   }

   fin.open("movies.txt"); // Assuming every line conatins a name and a gene

   count = 0;
   while (fin >> list[count].name >> list[count].genre){
         count++;
   }
  
   while(1){

        cout << "1.Darma ";
        cout << "2.Comedy ";
        cout << "3.Romance ";
        cout << "4.Action ";
        cout << "5.Thriller ";
        cout << "6.Adventure ";
        cout << "7.Quit ";

        cout << " Enter first choice for genre or Quit to exit:"<< endl;
        cin >> str;
        if (str == "Quit")
           break;
        cout << " Enter Second choices for genre or Quit to exit:"<< endl;
        cin >> str1;
        if (str1 == "Quit")
           break;
       
        count1 = 0;
       
        while (1){
           found = 0;
           for (int i = 0; i<count; i++){
                if (list[i].genre == str || list[i].genre == str1){
                   found = 1;
                   index = i;
                   found1 = 0;
                   for (int j = 0; j<count1; j++){
                    
                      if (d[j] == i){
                         found1 =1 ;
                        
                      }
                   }
                   if (found1 == 0){
                      d[count1] = i;
                      count1++;
                      break;
                   }
       
                }
            }
           if (found == 1){
              cout << list[index].name <<endl;
              cout << "Would you like to go for another movie (y/n):";
              cin >> choice;
              if (choice[0] == 'n')
                 break;
           }
           else {
              cout << "No movies found ";
              break;
           }
        }
            

   }
  
   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