Question

Congratulations! You’ve been inducted into the secret society of ~~~~~~~~. (Sorry, it’s so secret that I’m...

Congratulations! You’ve been inducted into the secret society of ~~~~~~~~. (Sorry, it’s so secret that I’m not allowed to tell you its name.)

Your mission is to read this uber-classified memo from the Grand Poobah of ~~~~~~~~. Of course, it’s in code, so you’ll need to write a program in C++ to decrypt your message.

The code is set up so that for the nth element in the array, you will need to read its nth letter. (Ex: if pirates is in array position 0, then print letter 0 of the word, which = p.

   if gangway is in array position 4, then print letter 4 = w.)

To accomplish this, your main function should do the following:

A. Declare 4 arrays of strings called secrets1, secrets2, secrets3, & secrets4 and assign them the following values:

secrets1: { "platypus", "plethora","trend", "croak","almost", "toaster" };

secrets2: { "fire", "seen","trend", "produce" };

secrets3: { "tiretread", "chains", "stern", "bed bug" };

secrets4: { "oracle", "stetson","mother", "stie", "twigrot" };

B. Call the function decode 4 times – once for each array from #a (in order)

C. Write a void function called decode that will

  1. Accept an array of strings, and the array length as the parameters.
  2. Read through each word in the array and print the correct secret letter for that word. (Print all of the letters from this array on one line.)
  3. Print a blank line
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

#include<iostream>

using namespace std;

//method to decode the plain text hidden in an array of strings

void decode(string arr[], int length){

                //looping through each element

                for(int i=0;i<length;i++){

                                //printing ith character of element at index i

                                cout<<arr[i][i];

                }

                //line break

                cout<<endl;

}

int main(){

                string secrets1[] { "platypus", "plethora","trend", "croak","almost", "toaster" };

                string secrets2[] { "fire", "seen","trend", "produce" };

                string secrets3[] { "tiretread", "chains", "stern", "bed bug" };

                string secrets4[] { "oracle", "stetson","mother", "stie", "twigrot" };

               

                //decoding all 4 arrays

                decode(secrets1,6);

                decode(secrets2,4);

                decode(secrets3,4);

                decode(secrets4,5);

                return 0;

}

/*OUTPUT*/

please

feed

the

otter

Add a comment
Know the answer?
Add Answer to:
Congratulations! You’ve been inducted into the secret society of ~~~~~~~~. (Sorry, it’s so secret that I’m...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT