A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
[E] encipher
[D] decipher
[X] Exit
Enter choice: e(user input)
Enter message to encrypt: (user input)
Enter key:user input)
The encrypted message:
Back to main menu?
(Yes/No) YES (return to menu if NO, program exits) : y (user input)
Enter choice:d(user input)
Enter message to decrypt:(user input)
Enter key:(user input)
The decrypted message is:
Back to main menu? (y/n): N (user input)
MY PROBLEM ARE HOW TO CREATE CODES FOR ENTER KEY,BACK TO MAIN MENU, why there exist a no. when the user type it. it should be A-Z only and also the spacing what the code for SPACING? PLEASE HELP..
THIS IS MY CODE. WHATS THE LACKING OF MY CODES?AM I PUT STRING PASSWORD?
#include <iostream>
#include <string>
char getmenuselection()
{
std::cout << "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n""[E] encipher\n""[D] decipher\n""[X] Exit]\n""Enter choice: " ;
char choice ;
std::cin >> choice ;
switch(choice)
{
case'E': case'e': return'E' ;
case'D': case'd': return'D' ;
case'X': case'x': return'X' ;
default:
std::cout << "Invalid entry, please try again\n" ;
return getmenuselection() ;
}
}
int main()
{
char sel ;
do
{
sel = getmenuselection() ;
switch(sel)
{
case'D':
std::cout << "decipher\n" ;
// code for decipher ...
break ;
case'E':
std::cout << "encipher\n" ;
// code for encipher...
break ;
case'X' :
std::cout << "exit\n" ;
return 0 ;
}
char repeat ;
std::cout << "Back to main menu? (y/n)? " ;
std::cin >> repeat ;
if( repeat != 'Y' && repeat != 'y' ) sel = 'X' ; // exit
}
while( sel != 'X' ) ;
}