Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ please Review the background of Closed Lab 6 if you need more of a refresher on Run-Length Encoding (RLE). Today we will be implementing

c++ please
image text in transcribed
image text in transcribed
image text in transcribed
Review the background of Closed Lab 6 if you need more of a refresher on Run-Length Encoding (RLE). Today we will be implementing the decompression/decoding side of the algorithm with a small twist. Recall that RLE encodes text by counting runs of characters. The input aaaaaabbbbbbaaaabbbccccc becomes 7a6b4a3b5c as noted in the picture below. Decoding would take the result 7a6b4a3b5c and reverse the process to output aaaaaabbbbbbaaaabbbccccc. An algorithm to decode would look something like the following: 1. Read the first integer value. 2. Read the first character value. 3. Repeatedly print the character out integer number of times. 4. Read the next integer value. 5. Read the next character value. 6. Repeatedly print the character out integer number of times. 7. Repeat steps 4-6 until the all input has been processed. For this assignment you will be implementing the decoding side of RLE. Write a program that prompts the user to enter a filename containing the RLE pairs of count character. Then open the file. If the file does not exists, print out an error message. If the file does exist, iterate through it from beginning to end reading each count and character pair. For each count/char pair, output the appropriate number of the character to stdout (use cout). Use the sample runs to ensure all of your output is correct. To make reading pairs from the input files easier, the files will contain whitespace between all counts and characters of the input. For example, instead of 7a6b4a3b5c as the input, the file would contain the information as 7 a 6 b 4 a 3 b 5 c. (all separated by a single space character). This is important to remember! The reason it will be this way is to save the trouble of figuring out what some input similar to 1201 a would be. Is it 120 's and 1 a? or is it 1201 a's? etc. By including spaces between all integer and character pairs the processing becomes easier. However, you will also need to make use of cin. get (ch) to "throw out" the irrelavent spaces. Program Requirements 1. Include all appropriate comments as usual. 2. Do not forget to close the file after you are done with it. 3. You must use a while loop to handle the loop reading information from the file. 4. You must use a for loop to handle the count/char output. 5. Use the sample runs to ensure that all output is spelled/spaced correctly. Enter filename to decompress: nofile.txt File nofile.txt does not exist! Sample Run 2 (fakefile.txt as input) Enter filename to decompress: fakefile.txt File fakefile.txt does not exist! Sample Run 3 (simplestring.txtas input) Enter filename to decompress: simplestring. dat RRRRRRRRRRRRRGGGGGGGGGRRRRRRRRRRBBRRRRRRRRRRRGGGRGRGGGGBBBBBBRRRRRRRR Sample Run 4 (cat.txt as input) Sample Run 5 (horse.txt as input)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions