Question: You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to



You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an output file. Assume that the user types any character when prompted to select a menu option. If an input file cannot be opened, the program prints an error message and reprints the menu as shown in the sample solution. The output file is assumed to open correctly. In addition to your main function, Your solution must include the following non-trivial functions: 1. A function to print out the menu - a void function. Output statements only 2. A function that returns any integer value entered by the user 3. A function to open an input filet - may want to use as a Boolean value returning function 4. A function to open an output file 5. A function for compression? 6. A function for decompression? 'These functions require 1 reference parameter - an input file stream or output file stream variable. These functions must be used to open the files. 2These functions require 2 reference parameters - an input and an output file stream variable Example The compression scheme is illustrated below. Decompressed Text Compressed Text Observations abbccc 1a2b3c2 la 1 copy of a, 2b + 2 copies of b,... 4d1 2 2 copies of and so on dddd Note #1: represents a newline character Note #2: You should be able to take a file compressed by your program and use your program to decompress it and recover the original file. In other words, if Option 1 compresses X to produce the file Y, then Option 2 should decompress Y to produce a file Z that is identical to X.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
