Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ with strings, need help with coding. The SecretCoding is an algorithm that you decided to make-up to encrypt text. In this algorithm, each string

C++ with strings, need help with coding.

The SecretCoding is an algorithm that you decided to make-up to encrypt text. In this algorithm, each string is encrypted as follows:

- All punctuations are discarded, this includes commas(,), dots(.), question marks(?), exclamation marks(!), semicolons (;), and colons(:).

- If the string starts with a vowel, move the last 3 letters to the beginning of the string then add the # symbol at the beginning.

- If the string starts with a consonant, move the first 3 letters to the end of the string and add the $ symbol to the end.

- For any string that is of length less than or equal to 3, reverse the order of the string and add a % to the beginning and end of the string.

The input text can be of any length. The text can be tokenized using different delimiters. In this homework the delimiter you will use is the blank( ). What this means is that if as an input you have the sentence: Hello, everyone! This is: COSC-1436. The tokens that comprise this sentence based on the delimiter you have and after discarding the punctuations, are:

Hello

everyone

This

is

COSC-1436

The encrypted text for this input string is: loHel$ #oneevery sThi$ %si% C-1436COS$

Use the string class to implement this algorithm. The program should prompt the user to enter a text to be encrypted, parse the text, process it and finally display the text encrypted based on the SecretCoding algorithm.

#include #include #include #include

using namespace std;

const int NUM_OF_TOKENS = 10;

int tokenize(string myString, string strArray[NUM_OF_TOKENS]){ istringstream iss(myString); string token; int i = 0; while (getline(iss, token, ' ')) { strArray[i] = token; i++; } return i; }

int main () {

// TODO: prompt the user to input a string // TODO: call the tokenize function // TODO: display the tokens // TODO: call a function to encrypt stings that starts with a vowel

// TODO: call a function to encrypt stings that starts with a consonant

// TODO: call a function to encrypt short strings // TODO: display the encrypted strings (the results)

return 0; }

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago