While messing around with Linux command line, your friend accidentally deleted all the media directories, while moving all individuals files into the main directory. There is now a need to examine each file and sort into to music.txt, movies.txt, and series.txt. unosrted input file is attached here: unsorted_media.txt

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

  • Use reptition to read one file at a time, then use a sequential control statement to sort.

Task 1: Setup Variables

1. Add unsorted_media.txt file to the resource files folder.

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

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

4. Declare three output file variables you will use inplace of cout for writing to music.txt, movies.txt, and series.txt.

5. Declare a variable to contain a media file of type string.

6. Declare a variable to contain a user keystroke choice, of type char.

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

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

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

3. Use a repitition control statement to determine if the variable from Task 1.3 has not yet reached the end of file.

4. If Task 2.3 returns TRUE, use the variable from 1.3 to assign value to the variable from Task 1.5.

5. Output to the user screen, "The file is entitled: ", and then output the variable from Task 1.5.

6. Prompt the user to "sort this into Movies (M), Music (U), or Series (S): ".

7. Use a sequential control statement to validate user input.

8. Use a sequential control statement to determine which variable from Task 1.4 to write the file.

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

1. Close the connection from the variable in Task 2.1.

2. Close the connection from the variables in Task 2.2.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.