Over spring break, I ran out of disk space! Multiple times over. Has this every happened to you? So, for this assignment you are going to experiment with compression schemes. You are told that the data that you are working with is only alphabetic (a-z, A-Z) and common punctuation (period, semicolon, exclamation point, question mark, and others if you’d like). Therefore, your idea is to compress every two characters together into a byte of memory – taking less overall space. The scheme that you use must be of your design (do not use the web or other resources – come up with the algorithm yourself! It is part of a problem solving exercise)

Your job will be to write the compression algorithm and test it out with a phrase – encoding it – and then subsequently decoding it:

  • Prompt the user
  • Allow the user to enter phrase or sentence
  • Read in a sentence (you must read it in using arrays of characters, not single character by single character. You may assume that there will be no more than 130 characters entered in by the user.
  • Apply the compression algorithm you design
  • Echoing the sentence result (as possible)
  • Decode the sentence, using the opposite algorithm
  • Display the resulting sentence and use the cstring library to show that the result is the same as the original sentence entered
  • Allow the user to continue this process until done

In the real world if we were to create this type of software, it would use an entire text document (possible in an external file (which we will learn about later in the term)). Since we have not yet talked external files or functions, your program will not do anything with the data once it is displayed. Think of this as just step 1 of a larger problem. Use this to practice loops, arrays, and the cstring library. You may add more to this program!

Things you should part of your program:

  • Make sure to prompt the user for any input requested. Make sure it is clear from your prompts what the user is expected to do.
  • The program should continue until the user wants to quit. Allow them to continue until they are done.
  • You may not use any global variables in this program!
  • You may not use the string class – instead use arrays of characters
  • You MAY use the cstring library (e.g., strcmp)
  • Make sure to use C++’s I/O (iostream library) for I/O
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only 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 fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.