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, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. andre was recently hired by an organization to check for system vulnerabilities. he is supposed to exploit these vulnerabilities and create a report on the extent of damage to which the system was susceptible. what position does andre hold in this organization? a. information security analyst b. information assurance manager c. penetration tester d. network security engineer e. chief information security officer
Answers: 2
question
Computers and Technology, 23.06.2019 22:30
How many points do i need before i can send a chat
Answers: 1
question
Computers and Technology, 24.06.2019 10:30
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
You know the right answer?
The program in CombinationCipher. cpp takes a message written by the user and puts it through multip...
Questions
question
Mathematics, 19.03.2020 09:32
question
Mathematics, 19.03.2020 09:32
Questions on the website: 13722363