In c++. The instructions are in the image. Please do not change existing code below just add to what is needed. I am very confused. Can you please show the input and output of the code it would help...


In c++. The instructions are in the image.
Please do not change existing code below just add to what is needed.
I am very confused. Can you please show the input and output of the code it would help very much. There is also a text file which is named
"input.txt"
and it reads.


Movie 1
1
Genre1
Movie 2
2
Genre2
Movie 3
3
Genre3
Movie 4
4
Genre4
Movie 5
5
Genre5



main.cpp


#include
#include
#include
#include "functions.h"



int main()
{


vector movies;

char option;




while (true)
{
printMenu();
cin >> option;
cin.ignore();
switch (option)
{
case 'A':
{
string nm;
int year;
string genre;
cout < "movie="" name:="">
getline(cin, nm);
cout < "year:="">
cin >> year;
cout < "genre:="">
cin >> genre;


//call you addMovie() here
cout < "added="" "="">< nm="">< "="" to="" the="" catalog"=""><>
break;
}
case 'R':
{

string mn;
cout < "movie="">
getline(cin, mn);
bool found;
found = //call you removeMovie()here

if (found == false)
cout < "cannot="" find="" "="">< mn=""><>
else
cout < "removed="" "="">< mn="">< "="" from="" catalog"=""><>
break;
}
case 'O':
{
string mn;
cout < "movie="" name:="">
getline(cin, mn);
cout <>
//call you movieInfo function here
break;


}
case 'C':
{
cout < "there="" are="" "="">< movies.size()="">< "="" movies="" in="" the="" catalog"=""><>
// Call the printCatalog function here
break;
}
case 'F':
{
string inputFile;

bool isOpen;
cin >> inputFile;

cout < "reading="" catalog="" info="" from="" "="">< inputfile=""><>
isOpen = //call you readFromFile() in here
if (isOpen == false)
cout < "file="" not="" found"=""><>
break;
}
case 'W':
{ string outputFile;

bool isOpen;
cin >> outputFile;

cout < "writing="" catalog="" info="" to="" "="">< outputfile=""><>
isOpen = //call you writeToFile() in here
if (isOpen == false)
cout < "file="" not="" found"=""><>
break;
}
}
if (option == 'Q')
{
cout < "quitting="">
break;
}
}
}



functions.h


#ifndef FUNCTIONS_H
#define FUNCTIONS_H


#include
#include
#include
//include necessary libraries


using namespace std;




// Define the structure "movie" here




void printMenu()
{
cout <>
cout < "menu:"=""><>
cout < "a="" -="" add="" movie"=""><>
cout < "r="" -="" remove="" movie"=""><>
cout < "o="" -="" output="" movie="" info"=""><>
cout < "c="" -="" output="" catalog="" info"=""><>
cout < "f="" -="" read="" file"=""><>

cout < "w="" -="" write="" file"=""><>

cout < "q="" -="" quit="" program"=""><>

cout < "choose="" an="" option:="">
}


void printMovieInfo(const string &mn, int yr, const string &gen)
{
cout <>
cout < "name:="" "="">< mn=""><>
cout < "year:="" "="">< yr=""><>
cout < "genre:="" "="">< gen=""><>
}


// Write the definition and implementation of the printCatalog function here


// Write the definition and implementation of the findMovie function here


// Write the definition and implementation of the addMovie function here


// Write the definition and implementation of the removeMovie function here


// Write the definition and implementation of the movieInfo function here
// You must use the following cout statement if the movie is not in the catalog:
// cout < "cannot="" find="" "="">< *movie="" name="" variable="" identifier*/=""><>


// Write the definition and implementation of the readFromFile function here


// Write the definition and implementation of the writeToFile function here


#endif


17.4 Programming Assignment 4 - Structs and File I/O<br>Problem:<br>You are asked to create a program for storing the catalog of movies at a DVD store using functions, files, and user-defined structures. The<br>program should let the user read the movie through the file, add, remove, and output movies to the file.<br>For this assignment, you must store the information about the movies in the catalog using a single vector. The vector's data type is a<br>user-defined structure that you must define on functions.h following these rules:<br>• Identifier for the user-define structure: movie.<br>• Member variables of the structure
COSC 1437: Introduction to Programming home > 17.4: Programming Assignment 4 - Structs and File I/O zyBooks catalog ? Help/FA Movie Name n (string) YearN (int) GenreN (string) Given the previous format for the input file (where each field of a movie is stored in one line), here is an example of an input file: Terminator 1984 Action The Goonies 1985 Fiction Avengers 2012 Action 7) writeToFile: this function receives the following arguments: • A string with the name of the output file • A vector with the catalog of movies The function stores the information from the movie catalog in the output file. This function returns true (boolean) if the program can open the file specified by the first argument or false (boolean) if the program cannot open the file specified by the first argument. You must save the information about the movie catalog using the format of an input file presented above (each field of a movie is stored in one line). HINT: Make sure that this function does not add an end-of-line character at the end of the file. "/>
Extracted text: 17.4 Programming Assignment 4 - Structs and File I/O Problem: You are asked to create a program for storing the catalog of movies at a DVD store using functions, files, and user-defined structures. The program should let the user read the movie through the file, add, remove, and output movies to the file. For this assignment, you must store the information about the movies in the catalog using a single vector. The vector's data type is a user-defined structure that you must define on functions.h following these rules: • Identifier for the user-define structure: movie. • Member variables of the structure "movie": name (string), year (int), and genre (string). Note: you must use the identifiers presented before when defining the user-defined structure. Your solution will NOT pass the unit test cases if you do not follow the instructions presented above. The main function is provided (you need to modify the code of the main function to call the user-defined functions described below). The following user-defined functions are provided in the functions.h template file printMenu: this function does not receive arguments and does not return a value. The function prints the options from the menu to STDOUT. Menu: A - Add Movie R - Remove Movie O - Output Movie Info C - Output Catalog Info R- Read file W- Write file Quit Program printMovielnfo: this function receives the following arguments: A string representing the movie name. An integer representing the year of the movie. A string representing the movie genre. The function prints the information about a movie (name, year, and genre) and does not return a value. You must write the following user-defined functions: 1) printCatalog: this function receives the following arguments: -A vector with the catalog of movies. The function prints the information about each movie in the catalog using the output messages provided in the printMovielnfo function and does not return a value. 2) findMovie: this function receives the following arguments: • A string representing the movie name. • A vector with the catalog of movies. The function returns the index at which the movie name is located in the vector with the names of the movies in the catalog. If the movie is not in the catalog, the function must return -1. HINT: You may have to use this function in other functions. 3) addMovie: this function receives the following arguments: • A string representing the name of the movie to be added to the catalog. • An integer representing the year of the movie to be added to the catalog. • A string representing the genre of the movie to be added to the catalog. • A vector with the catalog of movies. The function adds the information about the new movie to the corresponding vectors and does not return a value. 4) removeMovie: this function receives the following arguments: • A string representing the name of the movie to be removed from the catalog. • A vector with the catalog of movies. If the movie is in the catalog, the function removes all the information about the movie from the vectors representing the catalog. The function returns true (boolean) if the movie was removed from the catalog or false (boolean) if the movie was not found. HINT: You may have to call another function within this function. 5) movielnfo: this function receives the following arguments: • A string representing the name of the movie to find in the catalog. • A vector with the catalog of movies. If the movie is in the catalog, the function outputs the information about the movie using the output messages provided in the printMovielnfo function. If the movie is not found, then the function must print to STDOUT the following message: cout < "cannot="" find="" "="">< *movie="" name="" identifier*/="">< endl;="" this="" function="" does="" not="" return="" a="" value.="" hint:="" you="" may="" have="" to="" call="" another="" function="" within="" this="" function.="" 6)="" readfromfile:="" this="" function="" receives="" the="" following="" arguments:="" •="" a="" string="" with="" the="" input="" file="" name="" •="" a="" vector="" with="" the="" catalog="" of="" movies="" the="" function="" reads="" the="" movie="" information="" from="" the="" input="" file="" and="" appends="" them="" to="" the="" catalog.="" this="" function="" returns="" true="" (boolean)="" if="" the="" program="" can="" open="" the="" file="" specified="" by="" the="" first="" argument="" or="" false="" (boolean)="" if="" the="" program="" cannot="" open="" the="" file="" specified="" by="" the="" first="" argument.="" the="" information="" about="" the="" catalog="" of="" movies="" is="" stored="" in="" the="" input="" file="" using="" the="" following="" format:="" movie="" name="" 1="" (string)="" yearl="" (int)=""> COSC 1437: Introduction to Programming home > 17.4: Programming Assignment 4 - Structs and File I/O zyBooks catalog ? Help/FA Movie Name n (string) YearN (int) GenreN (string) Given the previous format for the input file (where each field of a movie is stored in one line), here is an example of an input file: Terminator 1984 Action The Goonies 1985 Fiction Avengers 2012 Action 7) writeToFile: this function receives the following arguments: • A string with the name of the output file • A vector with the catalog of movies The function stores the information from the movie catalog in the output file. This function returns true (boolean) if the program can open the file specified by the first argument or false (boolean) if the program cannot open the file specified by the first argument. You must save the information about the movie catalog using the format of an input file presented above (each field of a movie is stored in one line). HINT: Make sure that this function does not add an end-of-line character at the end of the file.
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here