Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ with Strings NEED HELP URGENT The SecretCoding is an algorithm that you decided to make-up to encrypt text. In this algorithm, each string is

C++ with Strings NEED HELP URGENT

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago