Question: Using C++ For this I am required to reuse a single string variable for each entry. I cannot work it out. Your friend is organizing

Using C++

For this I am required to reuse a single string variable for each entry. I cannot work it out.

Your friend is organizing a Halloween party, and would like to display some horror movies as background entertainment. This friend would like to poll some guests to find the three best movies to play during the party, and has provided a file with 30 movies to choose from. You are tasked with writing a program that will display the movies to choose from, and then give the user a chance to vote for the top three movies. In the interest of time, your friend will hand count the results to choose the films. Your file of films to choose from is here:

horror_movies.txt

Your program should:

Prompt the user to review a list of 30 movies

Prompt the user to press any key to continue

Prompt the user to individually select or reject movies using 'y' or 'n'

Write each selection to an output file

Stop the selection process after the third movie is selected

Output the selections to the screen for the user to review

The program should utilize a minimum of four defined functions

Constraints:

Do not use any concepts beyond the current chapter, unless explicitly stated in the tasks below

Re-use a single string variable for each entry

Hint:

Each individual function should perform only one function.

You may call a function from within a function.

You may use a string value to represent the file name, instead of hard-coding. example, string filename = "filename.txt" file_input.open(filename);

Task 1: Setup Variables

Add horror_movies.txt to the resource files folder

Use preprocessor directives to include input/output, file input/output, and string variables.

Declare the input file variable you will use in place of cin for horror_movies.txt.

Declare the output file variable you will use inplace of cout for writing to party_selections.txt.

Declare a variable to contain a single movie title, of type string.

Declare a variable to contain the horror_movies.txt file, of type string.

Declare a variable to contain the party_selections.txt file, of type string.

Declare a variable to contain a count, of type int.

Declare a variable to contain a previous value of count, of type int.

Separate Task 1 from Task 2 by pressing ENTER on your keyboard. This provides a single line of whitespace in your code

Task 2: Input / Output Data

Use the variable from Task 1.3 to open the text file in Task 1.1.

Use the variables from Task 1.4 to open the text file indicated in Task 1.4.

Prompt the user to review the movie list, and then explain that the user is to choose three movies ( see sample run below ).

Display the original list of movies to the user, use a function that take a single string argument with the variable from Task 1.6.

Use a repetition control statement to handle user selection of individual films. This control statement should also count the number of selections.

This control statement should end when the count reaches 3.

Use a function that will take the current count, and a single movie title as an argument.

This function should prompt the user to "\t\t Press y to select " << mv << " or n to reject: " ( see second image for sample run below ).

The control statement should write to the output file from Task 1.4 each time the old count doesn't match the current count. Use a boolen returning function that takes old count and current count as arguments to handle this.

Separate Task 2 from Task 3 by pressing ENTER on your keyboard. This provides a single line of whitespace in your code

Task 3: Cleanup

Close the connection from the variable in Task 2.1.

Close the connection from the variables in Task 2.2.

Reset the screen with a "press any key to continue..." and "clear screen" command. Use a void function to handle this functionality.

Use the function from Task 2.4, but use the variable from Task 1.7. This will display the final selections.

Movie_list

28_Days_Later_(2002).mkv An_American_Werewolf_in_London_(1981).mkv Bay_of_Blood_(1971).mkv The_Birds_(1963).mkv The_Black_Cat_(1934).mkv The_Cabinet_of_Dr._Caligari_(1920).mkv Carrie_(1976).mkv Cemetery_Man_(1994).mkv Christine_(1983).mkv Dawn_of_the_Dead_(1978).mkv Dracula_(1931).mkv Eraserhead_(1977).mkv The_Exorcist_(1973).mkv Eyes_Without_a_Face_(1960).mkv Frankenstein_(1931).mkv Freaks_(1932).mkv Halloween_(1978).mkv Hellraiser_(1987).mkv Night_of_the_Living_Dead_(1968).mkv A_Nightmare_on_Elm_Street_(1984).mkv Nosferatu_(1922).mkv Poltergeist_(1982).mkv Psycho_(1960).mkv Re-Animator_(1985).mkv Ringu_(1998).mkv Rosemary's_Baby_(1968).mkv The_Shining_(1980).mkv The_Texas_Chainsaw_Massacre_(1974).mkv Videodrome_(1983).mkv The_Wicker_Man_(1973).mkv

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!