Question: I'm newer to C++ program so please someone help me solve these problems. Below is my code that I done half of it, but there're

I'm newer to C++ program so please someone help me solve these problems. Below is my code that I done half of it, but there're two part that I didn't get it like printout and encryptall. Thank you so much for your help.

Here is the assigment.

PROBLEM: You are to write a program in C++ that takes in as input a string message and an integer. The program will then scramble the message by converting each character of the message to its numeric code, adding the specified integer to this code, and then converting the resulting number back to a character. To do this, you must create a class that handles a string and an encoding integer. Required Class Variables: Should include a string to hold the message, and an int to hold the value to alter the message by.

Required Member Functions: encrypt - which will take in a single letter and return a result of type char. encryptAll - which will manipulate class variables in a loop to encrypt all of them. getMessage - which will read in a store the message string in a class variable. getCode - which will read in and store the encoding value. printOut - which will print out the current values of the class variables. To make it more readable, make sure that you skip spaces in the string (don't change them). For example, on our ASCII machines, the message:

THE REDCOATS ARE COMING!

and the integer 5 would produce: YMJ WJIHTFYX FWJ HTRNSL&

=========================================================================================================

#include

#include

using namespace std;

class Redcoats

{

public:

void getMessage();

void getCode();

void printOut();

private:

string message;

int code;

char encrypt(char);

string encryptAll();

};// end Redcoats class

int main()

{

Redcoats redcoat;

redcoat.getMessage();

redcoat.getCode();

redcoat.printOut();

return 0;

}//end main

void Redcoats::getMessage()

{

cout << "Enter a message to encrypt: ";

getline(cin, message);

cout << "The message you entered is: " << message << endl << endl;

}// end getMessage

void Redcoats::getCode()

{

cout << "Enter the code with which to encrypt the message: ";

cin >> code;

cout << "The code entered is: " << code << endl << endl;

}// end getCode

void Redcoats::printOut()

{

int

}

char Redcoats::encrypt (char ch)

{

if (ch == ' ')

return ch;

else

static_cast(ch + code);

return ch;

}

string Redcoats::encryptAll()

{

unsigned int n;

for (n = 0; n < message.length() - 1; n++)

{

if (messageArray[n] = encrypt(message.charAt(n))

cout << messageArray[n] << message << endl << endl;

}

return message;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!