Question: encrypt.cpp: #include #include #include encrypt.h / / Function to shift characters char shift _ char ( char c , int shift ) { if
encrypt.cpp:
#include #include #include "encrypt.h Function to shift characters char shiftcharchar c int shift if c a && c z return ac a shift ; else if c return z; Encrypt space to z return c; Encrypt single char char encryptchar c int shift return shiftchartolowerc shift; Decrypt single char char decryptchar c int shift return shiftchartolowercshift; void processchar mode, int shift, char dir int effectiveshift dir lshift : shift; std::string phrase; std::cout "Enter the phrase to mode e "encrypt: : "decrypt: ; 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;
main.cpp:
#include #include #include "encrypt.h 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.
; while choice e && choice d && choice q; return choice; void getoptsint &shift, char &dir cout "Enter the direction of the shift lr: ; cin dir; cout "Enter the shift number integer: ; cin shift; std::cin.ignorestd::numericlimits::max
; Clear the input buffer Main program entry point. int main char choice; do choice mainmenu; if choice e choice d int shift; char dir; getoptsshift dir; processchoice shift, dir; Call process to perform encryptiondecryption while choice q; std::cout "Goodbye!
; return ;
HOW TO FIX OUTPUT:
TO GET:
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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
