[C++]
Outline:
The movie data is read from a file into an array of structs and is sorted using the Selection Sort method and the search is done using the Binary Search algorithm with the year of release as key. This assignment upgrades to an array of pointers to the database elements and converts the Selection Sort and Binary search procedure on the database to selection sort and binary search on the array of pointers to the database.


Requirements:
Your data structure will now be an array of pointers. Each element of the array will now point to a MovieData record. The function headers will have an array of pointers as parameter. Accessing the movie data record fields will be done using pointer access mechanisms (using indirection ->) as in the example above. Make all the array related access including function parameters to a pointer array.
You are given a file called MovieData.txt that contains the following information:
The following fields are separated by a comma. Each movie is on a separate line in the file.
Title: String containing the title of the movie
ReleaseYear: int in the format YYYY
Director: String
Genre : String : Comedy, Thriller etc.
Starring: String: Holds the name of two leading characters.

MovieData.txt:
The Sound of Silence,2000, John Calaveras, Romance, Julie
Sheppard, Robert De Niro
Black Beauty,1975, Neil Diamond, Animals, Tatum O Neill, Ryan O
Neill
Amazing Grace,1950, William Keyford, Historical, Ben Shapiro, Meryl
Screen
Star Wars,1972, Luke SkyWalker, Science Fiction, William Shatner,
Leonard Nimoy
The GodFather,1980, Frances Ford Coppola, Thriller, Al Pacino, Myra
Adams
The Shining,1990, Stephen King, Horror, Jack Nichols, Amanda
Green
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================

// MovieDataFile.txt (input file)
The Sound of Silence,2000, John Calaveras, Romance, Julie
Sheppard, Robert De Niro
Black Beauty,1975, Neil Diamond, Animals, Tatum O Neill, Ryan O
Neill
Amazing Grace,1950, William Keyford, Historical, Ben Shapiro, Meryl
Screen
Star Wars,1972, Luke SkyWalker, Science Fiction, William Shatner,
Leonard Nimoy
The GodFather,1980, Frances Ford Coppola, Thriller, Al Pacino, Myra
Adams
The Shining,1990, Stephen King, Horror, Jack Nichols, Amanda
Green
======================================
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;
struct Movie {
string title;
int releaseYear;
string director;
string genre;
string starring;
};
void menu();
void selectionSort(Movie* movies, int count);
void display(Movie* movies, int count);
int search(Movie* movies, int count, int year);
int main()
{
//Declaring variables
char choice;
string line;
int count = 0;
int index = -1;
int year;
string title, director, genre, starring;
ifstream dataIn;
dataIn.open("MovieDataFile.txt");
//checking whether the file name is valid or not
if (dataIn.fail()) {
cout << "** File Not Found **";
return 1;
}
else {
//Reading the data from the file
while (getline(dataIn, line)) {
count++;
}
dataIn.close();
Movie* movies = new Movie[count];
dataIn.open("MovieDataFile.txt");
for (int i = 0; i < count; i++) {
getline(dataIn, line);
index = line.find(",");
title = line.substr(0, index);
line = line.substr(index + 1, line.length() - 1);
index = line.find(", ");
year = atoi(line.substr(0, index).c_str());
line = line.substr(index + 1, line.length() - 1);
index = line.find(", ");
director = line.substr(0, index);
line = line.substr(index + 1, line.length() - 1);
index = line.find(", ");
genre = line.substr(0, index);
starring = line.substr(index + 1, line.length() - 1);
movies[i].title = title;
movies[i].releaseYear = year;
movies[i].director = director;
movies[i].genre = genre;
movies[i].starring = starring;
}
dataIn.close();
selectionSort(movies, count);
while (true) {
menu();
cin >> choice;
switch (choice) {
case 'D':
case 'd': {
display(movies, count);
continue;
}
case 'S':
case 's': {
cout << "Please enter the year of the movie in yyyy format
:";
cin >> year;
int index = search(movies, count, year);
if (index == -1) {
cout << "Movie Not found" << endl;
}
else {
cout << setw(25) << left << movies[index].title
<< setw(10) << left << movies[index].releaseYear
<< setw(25) << left << movies[index].director
<< setw(20) << left << movies[index].genre
<< setw(25) << left << movies[index].starring
<< endl;
}
continue;
}
case 'Q':
case 'q': {
cout << "GoodBye!" << endl;
break;
}
default: {
cout << "** Invalid Choice **" << endl;
continue;
}
}
break;
}
}
return 0;
}
void selectionSort(Movie* arr, int SIZE)
{
int minIndex;
Movie temp;
for (int i = 0; i < SIZE - 1; i++) {
minIndex = i;
for (int j = i + 1; j < SIZE; j++) {
if (arr[j].releaseYear < arr[minIndex].releaseYear)
minIndex = j;
}
// swap array
if (minIndex != i) {
temp = arr[i];
arr[i] = arr[minIndex];
arr[minIndex] = temp;
}
}
}
void menu()
{
cout << "Movie Selection Menu" << endl
<< endl;
cout << "Display available Movies : D" <<
endl;
cout << "Search a Movie by Year : S" << endl;
cout << "Quit : Q" << endl;
cout << "Enter Your choice :";
}
void display(Movie* movies, int count)
{
for (int i = 0; i < count; i++) {
cout << setw(25) << left << movies[i].title
<< setw(10) << left << movies[i].releaseYear
<< setw(25) << left << movies[i].director
<< setw(20) << left << movies[i].genre <<
setw(25) << left << movies[i].starring <<
endl;
}
}
int search(Movie* array, int count, int year)
{
int first = 0, last = count - 1, middle, position = -1;
bool found = false;
while (!found && first <= last) {
middle = (first + last) / 2;
if (array[middle].releaseYear == year) {
found = true;
position = middle;
}
else if (array[middle].releaseYear > year)
last = middle - 1;
else
first = middle + 1;
}
return position;
}
==========================================
Output:

=====================Could you plz rate me
well.Thank You
[C++] Outline: The movie data is read from a file into an array of structs and...
Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...
This lab will combine reading data from a file and searching the
array to find a specific value.
Assignment
Write a program that reads in a file full of strings into an
array, and prompts the user for a string to find in the array. The
program should loop until a sentinel value (such as -1) is
entered.
After looping in main() for the input, write a search function,
with the following prototype:
int findWord(string [], int, string);
with arguments...
For your second program, please read the data from the input file directly into an array. (You may safely dimension your array to size 300.) Then close the input file. All subsequent processing will be done on the array. Your program should have two functions besides main(). The first function will print out the contents of the array in forward order, 10 numbers per line, each number right justified in a 5 byte field. The second function will print out...
You are going to implement Treesort algorithm in C++ to sort string data. Here are the steps to complete the homework 1) Use the following class definition for binary search tree nodes. Its constructor is incomplete you should first complete the constructor. class TreeNode t public: string data; / this is the string stored in the node TreeNode left: TreeNode right; TreeNode (string element, TreeNode 1t, TreeNode rt //your code here 2) Write a function that will insert a string...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...
WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL PASTE AT BOTTOM MOVIES.CPP #include "movies.h" #include "Movie.h" Movies *Movies::createMovies(int max) { //dynamically create a new Movies structure Movies *myMovies = new Movies; myMovies->maxMovies = max; myMovies->numMovies = 0; //dynamically create the array that will hold the movies myMovies->moviesArray = new Movie *[max]; return myMovies; } void Movies::resizeMovieArray() { int max = maxMovies * 2; //increase size by 2 //make an array that is...
C programming The program will require the following structure: struct _data { char *name; long number; }; The program will require command line arguments: int main(int argv, char **argc) { Where argv is the number of arguments and argc is an array holding the arguments (each is a string). Your program must catch any case where no command line arguement was provided and print a warning message (see below). You MUST include/use the following functions, defined as follows: int SCAN(FILE...
Update your first program to dynamically allocate the item ID and GPA arrays. The number of items will be the first number in the updated “student2.txt” data file. A sample file is shown below: 3 1827356 3.75 9271837 2.93 3829174 3.14 Your program should read the first number in the file, then dynamically allocate the arrays, then read the data from the file and process it as before. You’ll need to define the array pointers in main and pass them...
Hello, I need to implement these small things in my C++ code. Thanks. 1- 10 characters student first name, 10 characters middle name, 20 characters last name, 9 characters student ID, 3 characters age, in years (3 digits) 2- Open the input file. Check for successful open. If the open failed, display an error message and return with value 1. 3- Use a pointer array to manage all the created student variables.Assume that there will not be more than 99...
IN C ONLY As mentioned earlier there are two changes we are going to make from lab 5, The file you read into data structures can be any length. studentInfo array will be stored in another struct called studentList that will contain the Student pointer and current length of the list. Sometimes data can be used in structs that correlate between variables so it's convenient to store the data in the same struct. Instead of tracking a length variable all...