Solution:
lab10movies.cpp
#include<iostream>
#include<string>
#include<fstream>
struct Movie
{
std::string movieName;
int yearReleased;
};
//TODO: create a struct called Movie
//TODO: in the struct use a string called movieName to store the
movie name
//TODO: in the struct use an int called yearReleased to store the
year
//node represents a single node in the linked list
struct node
{
Movie aMovie;
node* prevPtr;
};
//Function: menu is used to display an interactive menu to the
user
void menu();
//TODO: create a function prototype called showBeforeYear
//TODO: showBeforeYear takes two inputs: a node* and an int
void showBeforeYear(node*,int);
//Function: listMovies is used to display all movies in the
linked list
void listMovies(node*);
int main()
{
std::ifstream inputHandler;
//file handler for input file
std::string movieNameFromFile; //store
movie name from file
int movieYearFromFile;
//store movie year from file
int userInput;
//get user
input for menu interaction
int userYear;
//get year
from user to list movies
node* currentPtr = NULL;
//currentPtr points to current list element,
initialized to NULL
node* headPtr = NULL;
//headPtr points to top of list, initialized to
NULL
//Open the movies.text file
inputHandler.open("movies.txt");
//Read the first line from the file
inputHandler >> movieNameFromFile >>
movieYearFromFile;
while (!inputHandler.eof())
{
//create a new node called
currentPtr
currentPtr = new node;
//TODO: set the value for
currentPtr to the values read from the file
currentPtr->aMovie.movieName=movieNameFromFile;
currentPtr->aMovie.yearReleased=movieYearFromFile;
//set currentPtr->prevPtr to
headPtr
currentPtr->prevPtr =
headPtr;
//update headPtr to
currentPtr
headPtr = currentPtr;
//read the next line from the
file
inputHandler >>
movieNameFromFile >> movieYearFromFile;
}
//Close the file
inputHandler.close();
//Display the menu to the user
menu();
std::cin >> userInput;
//Validate input
while (userInput > 3 || userInput < 1)
{
//Display the menu to the
user
menu();
std::cin >> userInput;
}
//List movies by year
if (userInput == 1)
{
//TODO: ask the user to enter the
year
//TODO: store the year entered by
the user in userYear
//TODO: call function
showBeforeYear with currentPtr and userYear
std::cout<<"Enter an
year:";
std::cin>>userYear;
showBeforeYear(currentPtr,userYear);
return 0;
}
//List all movies
else if (userInput == 2)
{
//Call function listMovies to print
all movies
listMovies(currentPtr);
return 0;
}
//Exit program
else
{
//Show exit message and terminate
program
std::cout << "Exiting
program." << std::endl;
return 0;
}
}
//Function: menu
//Inputs: none
//Outputs: none
//Errors: none
void menu()
{
std::cout << "Press 1 to list movies released
before a specific year." << std::endl;
std::cout << "Press 2 to list all movies."
<< std::endl;
std::cout << "Press 3 to quit." <<
std::endl;
std::cout << "Enter your choice: ";
}
//TODO: create function showBeforeYear
//Function: showBeforeYear
//Inputs: node* currentPtr and int userYear
//Outputs: displays all movies before a specific year
//Errors: none
void showBeforeYear(node* currentPtr, int userYear)
{
//TODO: function showBeforeYear should list all movies
released before userYear
//TODO: if you find 0 movies before userYear, tell the
user that you found no movies
int movies=0;
while(currentPtr)
{
if(currentPtr->aMovie.yearReleased<userYear)
{
movies++;
std::cout<<currentPtr->aMovie.movieName<<"
"<<currentPtr->aMovie.yearReleased<<"\n";
}
currentPtr=currentPtr->prevPtr;
}
if(movies==0)
std::cout<<"No movies
found";
}
//Function: listMovies
//Inputs: node* currentPtr
//Outputs: displays all movies stored in linked list
//Errors: none
void listMovies(node* currentPtr)
{
//Loop until currentPtr hits NULL
while(currentPtr)
{
//Print entry from linked
list
std::cout <<
currentPtr->aMovie.movieName << " released in " <<
currentPtr->aMovie.yearReleased << std::endl;
//Move currentPtr to next
location
currentPtr =
currentPtr->prevPtr;
}
}
movies.txt:
Alice_in_Wonderland 2010
Avatar 2009
Avengers:_Age_of_Ultron 2015
Despicable_Me_2 2013
Finding_Dory 2016
Finding_Nemo 2003
Frozen 2013
Furious_7 2015
Iron_Man_3 2013
Jurassic_Park 1993
Jurassic_World 2015
Minions 2015
Shrek_2 2004
Skyfall 2012
Spectre 2015
Spider-Man_3 2007
The_Avengers 2012
The_Dark_Knight 2008
The_Dark_Knight_Rises 2012
The_Jungle_Book 2016
The_Lion_King 1994
The_Secret_Life_of_Pets 2016
Titanic 1997
Toy_Story_3 2010
Zootopia_film 2016
Output:


The file lab10movies.cpp contains a program that allows the user to read movie names and movie re...
Topics: list, file input/output (Python) You will write a program that allows the user to read grade data from a text file, view computed statistical values based on the data, and to save the computed statistics to a text file. You will use a list to store the data read in, and for computing the statistics. You must use functions. The data: The user has the option to load a data file. The data consists of integer values representing student...
Python Programming Topics: list, file input/output You will write a program that allows the user to read grade data from a text file, view computed statistical values based on the data, and to save the computed statistics to a text file. You will use a list to store the data read in, and for computing the statistics. You must use functions. The data: The user has the option to load a data file. The data consists of integer values representing...
[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...
Finish FormatJavaProgram.java that prompts the user for a file name and assumes that the file contains a Java program. Your program should read the file (e.g., InputFile.java) and output its contents properly indented to ProgramName_Formatted.java (e.g., InputFile_Formatted.java). (Note: It will be up to the user to change the name appropriately for compilation later.) When you see a left-brace character ({) in the file, increase your indentation level by NUM_SPACES spaces. When you see a right-brace character (}), decrease your indentation...
Netflix Database - PROGRAMMED IN JAVA PLEASE :) In this program, you will build a Netflix movie database using the provided file, netflix.csv. The file contains more than two hundred records of movies and TV programs, with each record consisting a title, a rating, a release year, and a user rated score. There are three classes that you will need to implement: Movie, NetflixHandler, and NetflixApp. Class: Movie Movie - title: String - rating: String - year: int - score:...
Using the program segment and sample txt file below, write a program that contains a linked list of students. The program should allow the user to: 1. initialize list of students 2. add additional student to front of list 3. add additional student to rear of list 4. delete student 5. sort students alphabetically 6. sort students by idNum 7. show number of students in list 8. print students 9. quit program XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The program should be divided into the...
C++ Objective: Write a program to read a pre-specified file containing salespersons' names and daily sales for some number of weeks. It will create an output file with a file name you have gotten from the user that will hold a summary of sales data. Specifications: 1. You should do a functional decomposition to identify the functions that you will use in the program. These should include reading and writing the files, tallying and showing statistics, etc. 2. The program...
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...
Need this in C++ Goals: Your task is to implement a binary search tree of linked lists of movies. Tree nodes will contain a letter of the alphabet and a linked list. The linked list will be an alphabetically sorted list of movies which start with that letter. MovieTree() ➔ Constructor: Initialize any member variables of the class to default ~MovieTree() ➔ Destructor: Free all memory that was allocated void printMovieInventory() ➔ Print every movie in the data structure in...
LAB 7-Movie List Program Goali Your assignment is to write a C++program to implement the ADT List by creating a list of movies. This assignment will help you practice: multiple file programming, classes, pablic and private methods, dynamie memory, constructors and destructors, arrays and files Implementation the required classes This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of There are two classes to implement: Movie and MovieList. As you can see...