Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem Statement: The name of the file must be encrypt.cpp Write a program that

ID: 3732754 • Letter: P

Question

Problem Statement: The name of the file must be encrypt.cpp Write a program that prompts the user to enter a text to be encrypted, parse the text, process it and display the text encrypted using the following algorithm: -All punctuations are discarded, this includes commasu), dots(-), question marks(?) exclamation marks(l), semicolons G), 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 %, to the end of the string. You can read the input as a C-string or a string object, however, using string class for this homework is recommended. A tokenizing function should be used first, it will use the space ' as a delimiter. For example: "Hello, everyone! This is: COSC-1436, SP18" has 5 space delimiters 96 tokens

Explanation / Answer

#include <iostream>
#include<string> // for string class
// Tokenizing a string using stringstream
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main() {
  
string text;
  
cout<<"Please enter text to be encrypted:"<<endl;
getline(cin,text);
  
text.erase(std::remove(text.begin(), text.end(), ','), text.end());
text.erase(std::remove(text.begin(), text.end(), '?'), text.end());
text.erase(std::remove(text.begin(), text.end(), '!'), text.end());
text.erase(std::remove(text.begin(), text.end(), ':'), text.end());
text.erase(std::remove(text.begin(), text.end(), ';'), text.end());
  
// Vector of string to save tokens
vector <string> tok;

// stringstream class check1
stringstream check1(text);

string temp;

// Tokenizing w.r.t. space ' '
while(getline(check1, temp, ' '))
{
tok.push_back(temp);
}
\ use token
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote