Question: FIX THE LOOP WHEN I TYPE: . / a 1 Please select from the following options: Encrypt ( e ) Decrypt ( d ) Quit
FIX THE LOOP WHEN I TYPE:
a
Please select from the following options:
Encrypt e
Decrypt d
Quit q
Choice: e Enter the direction of the shift lr: r
Enter the shift number integer:
Enter the phrase to encrypt: every day is a sprinkle party
ALSO FIX THE OUTPUT SO IT MATCHES THE EXAMPLES:
Please select from the following options:
Encrypt e
Decrypt d
Quit q
Choice: e
Enter the direction of the shift lr: l
Enter the shift number integer:
Enter the phrase to encrypt: cats and dogs
Result: yqpxykaxaldp
Please select from the following options:
Encrypt e
Decrypt d
Quit q
Choice: d
Enter the direction of the shift lr: l
Enter the shift number integer:
Enter the phrase to decrypt: yqpxykaxaldp
Result: cats and dogs
ENCRYPT.CPP:
#include
#include
#include
#include "encrypt.h
Function to shift characters
char shiftcharchar c int shift
if c a && c z
return staticcastac a shift ;
else if c
return ;
return c;
Encrypt single char
char encryptchar c int shift
return shiftcharc shift;
Decrypt single char
char decryptchar c int shift
return shiftcharcshift;
void processchar mode, int shift, char dir
int effectiveshift dir lshift : shift;
std::string phrase;
std::cout "Enter the phrase to mode e "encrypt: : "decryp
t: ;
std::getlinestd::cin, phrase;
std::cout "Result: ;
for char c : phrase
if mode e
std::cout encryptc effectiveshift;
else
std::cout decryptc effectiveshift;
std::cout std::endl;
Define and use at least one useful private function
Public functions
Define and implement the functions declared in encrypt.h here.
MAIN.CPP:
#include
#include "encrypt.h
#include
using namespace std;
Function declarations
char mainmenu;
void getoptsint &shift, char &dir;
Display the main menu and return the selected option
char mainmenu
char choice;
do
std::cout "Please select from the following options:
;
std::cout "Encrypt e
Decrypt d
Quit q
;
std::cout "Choice: ;
cin choice;
if choice e && choice d && choice q
std::cout choice is not a valid option, try again.
;
