subject

The program in CombinationCipher. cpp takes a message written by the user and puts it through multiple ciphers. A cipher is a technique to create a secret code from a message. A combination cipher uses multiple ciphers to encode the same message. This combination cipher uses a Keyboard cipher twice and then uses Morse code. The Keyboard Code is just the order of letters your keyboard. The top row is the original letter, bottom row is the encoded letter.

The program in CombinationCipher. cpp file works, but it is ugly and harder to understand than it should be. That’s because it was written without functions other than main(). As a consequence, a lot of code gets repeated, and the overall logic of the program is hidden by the mass of details.
Rewrite the program by grouping the code into functions. Change the program so it takes the input from a file ‘input. txt’ instead of the terminal. In particular, your program should include the following functions:
1. A function named readInput that returns a string containing the message from a file. The parameter should be an fstream passed by reference.
A function named upperCase that returns nothing (void). The parameter should be one string containing the user entered message that gets modified to be all upper case letters. Hint: pass by reference.
A function named cipher that returns a string containing the fully encoded message. The parameter should be one string containing the uppercase user entered message.
A function named translateLetterKeyBoard that returns nothing (void). The parameter should be one char containing the letter to be modified, in accordance to the Keyboard cipher. Hint: pass by reference.
A function named translateLetterMorseCode that returns a string containing the char- acter in morse code. The parameter should be one char containing the letter to be translated, in accordance to Morse code.
A function named printOutput that returns nothing (void). The parameters should be two strings, the original user entered message and the final encoded message. This function should print the output.
As you introduce each function, replace the code in main() by calls to your new functions as appro- priate. In particular, note that some of these new functions may be called from within the bodies of some of the other functions.
Remember that this program was already working. You should not alter the output of the program in any way.
Hopefully, once you are done it will be obvious to you that your revised code is simpler and easier to understand than the original. In real life, code that is easier to understand, is easier to get working in the first place, so you should try to develop the code in small, function-based chunks from the very beginning.
To test your code you can always run inputs through the original .cpp and your own to compare the outputs.
Sample output of Task:
input. cpp:
#include
#include
using namespace std;
int main()
{
cout << "Assignment 0- Combination Cipher\n";
//Prompt the user for a string
string userInput ="";
cout << "Enter the string you would like encoded: ";
getline(cin, userInput);
string tempMessage =userInput;
//clean up the message and make all upper case
for(int i = 0; i < tempMessage. size(); i++)
tempMessage[i] = toupper(tempMessage[i]);
//Encode the message through KeyBoard Cipher
for(int i = 0; i < tempMessage. size(); i++){
char letter = tempMessage[i];
switch (letter){
case 'A':
letter = 'Q';
break;
case 'B':
letter = 'W';
break;
case 'C':
letter = 'E';
break;
case 'D':
letter = 'R';
break;
case 'E':
letter = 'T';
break;
case 'F':
letter = 'Y';
break;
case 'G':
letter = 'U';
break;
case 'H':
letter = 'I';
break;
case 'I':
letter = 'O';
break;

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Which law requires employers to provide safe working environments for their employees? a. civil rights act b. fair labor standards act c. occupational safety and health act d. wagner act
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Norder to receive financial aid at his vocational school, mario must fill out the fafsa. the fafsa is a form that must be completed to determine . in order to complete a fafsa, you must submit . the fafsa can students obtain
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a.edit the sizes and other characteristics of photos that have been inserted. b.take a screenshot of an image and copy it to the clipboard for pasting. c.search for drawings or other images from a library of prepared pictures. d.make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
question
Computers and Technology, 24.06.2019 10:20
Multiple choice project create a program with two multiple choice questions. 1. users have two attempts only, show attempt number each time. hint: while loop with break control. (20%) 2. only one correct answer for each question, use switch case for each question. (20%) 3. show total score after the two questions are answered. hint: . (20%) 4. user have options to answer the two questions again if first attempt score is not 100%. hint: if statment. (20%) 5. use string method .toupper() to allow users to enter with lowercase or uppercase letters. (20%) 1. where is the capital of the state of florida? a. orlando b. tallahassee c. miami d. tampa b 2. where is walt disney world park located in florida? a. orlando b. tallahassee c. miami d. tampa a
Answers: 1
You know the right answer?
The program in CombinationCipher. cpp takes a message written by the user and puts it through multip...
Questions
question
World Languages, 20.02.2020 00:57
question
English, 20.02.2020 00:57
Questions on the website: 13722363