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. Different

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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. Different solutions i have seen but i keep getting errors and errors i am still confused.

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

main.cpp

#include <iostream>
#include <vector>
#include <string>
#include "functions.h"

 

int main()
{

vector<movie> 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" << endl;
break;
}
case 'R':
{
string mn;
cout << "Movie Name:";
getline(cin, mn);
bool found;
found = //call you removeMovie()here
if (found == false)
cout << "Cannot find " << mn << endl;
else
cout << "Removed " << mn << " from catalog" << endl;
break;
}
case 'O':
{
string mn;
cout << "Movie Name: ";
getline(cin, mn);
cout << endl;
//call you movieInfo function here
break;

}
case 'C':
{
cout << "There are " << movies.size() << " movies in the catalog" << endl;
// Call the printCatalog function here
break;
}
case 'F':
{
string inputFile;
bool isOpen;
cin >> inputFile;
cout << "Reading catalog info from " << inputFile << endl;
isOpen = //call you readFromFile() in here
if (isOpen == false)
cout << "File not found" << endl;
break;
}
case 'W':
{ string outputFile;
bool isOpen;
cin >> outputFile;
cout << "Writing catalog info to " << outputFile << endl;
isOpen = //call you writeToFile() in here
if (isOpen == false)
cout << "File not found" << endl;
break;
}
}
if (option == 'Q')
{
cout << "Quitting Program";
break;
}
}
}

functions.h

#ifndef FUNCTIONS_H
#define FUNCTIONS_H

#include <iostream>
#include <vector>
#include <string>
//include necessary libraries

using namespace std;


// Define the structure "movie" here


void printMenu()
{
cout << endl;
cout << "Menu:" << endl;
cout << "A - Add Movie" << endl;
cout << "R - Remove Movie" << endl;
cout << "O - Output Movie Info" << endl;
cout << "C - Output Catalog Info" << endl;
cout << "F - Read file" << endl;
cout << "W - Write file" << endl;
cout << "Q - Quit Program" << endl;
cout << "Choose an option: ";
}

void printMovieInfo(const string &mn, int yr, const string &gen)
{
cout << endl;
cout << "Name: " << mn << endl;
cout << "Year: " << yr << endl;
cout << "Genre: " << gen << endl;
}

// 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*/ << endl;

// 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

## 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 manage the movie catalog through file operations, adding, removing, and outputting movies to a file.

### For this assignment:
- Store movie information using a single vector. 
- The vector’s data type is a user-defined structure with the following attributes:
  - Identifier: `movie`
  - Member variables of the structure `movie`:
    - `name` (string)
    - `year` (int)
    - `genre` (string)

**Note:** Use the identifiers as specified when defining the user-defined structure. Your code will not pass the unit test if you do not follow these instructions.

The main function is provided, and you need to modify it to call the user-defined functions described below.

### Provided User-defined Functions:
Functions are in the `functions.h` template file.

- **`printMenu`**: 
  - No arguments or return value.
  - Prints options to the STDOUT.

#### Menu Options:
```
A - Add Movie
R - Remove Movie
C - Output Movie Info
O - Output Catalog Info
R- Read file
W- Write file
Q - Quit Program
```

- **`printMovieInfo`**:
  - Receives: a movie name (string), year (int), and genre (string).
  - Prints movie information.

### Required User-defined Functions:

1. **`printCatalog`**:
   - Receives: a vector with the movie catalog.
   - Prints information about each movie.

2. **`findMovie`**:
   - Receives: a movie name (string) and a vector with the movie catalog.
   - Returns index of the movie in the catalog or `-1` if not found.

3. **`addMovie`**:
   - Receives: movie name (string), year (int), genre (string), and a catalog vector.
   - Adds the movie to the catalog.

4. **`removeMovie`**:
   - Receives: movie name (string) and the catalog vector.
   - Removes the movie from the catalog. Returns true if successful, false if not found.

5. **`movieInfo`**:
   - Receives
Transcribed Image 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 manage the movie catalog through file operations, adding, removing, and outputting movies to a file. ### For this assignment: - Store movie information using a single vector. - The vector’s data type is a user-defined structure with the following attributes: - Identifier: `movie` - Member variables of the structure `movie`: - `name` (string) - `year` (int) - `genre` (string) **Note:** Use the identifiers as specified when defining the user-defined structure. Your code will not pass the unit test if you do not follow these instructions. The main function is provided, and you need to modify it to call the user-defined functions described below. ### Provided User-defined Functions: Functions are in the `functions.h` template file. - **`printMenu`**: - No arguments or return value. - Prints options to the STDOUT. #### Menu Options: ``` A - Add Movie R - Remove Movie C - Output Movie Info O - Output Catalog Info R- Read file W- Write file Q - Quit Program ``` - **`printMovieInfo`**: - Receives: a movie name (string), year (int), and genre (string). - Prints movie information. ### Required User-defined Functions: 1. **`printCatalog`**: - Receives: a vector with the movie catalog. - Prints information about each movie. 2. **`findMovie`**: - Receives: a movie name (string) and a vector with the movie catalog. - Returns index of the movie in the catalog or `-1` if not found. 3. **`addMovie`**: - Receives: movie name (string), year (int), genre (string), and a catalog vector. - Adds the movie to the catalog. 4. **`removeMovie`**: - Receives: movie name (string) and the catalog vector. - Removes the movie from the catalog. Returns true if successful, false if not found. 5. **`movieInfo`**: - Receives
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 13 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education