English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

ok i have the program running theres just one detail i need to fix
one last detail
heres the relevant part of the program
int option;
cout<<"Enter 1 to encrypt, 2 to decrypt, 3 to quit"< cin>>option;
while (option!=3) {
if (option==1) {
cout<<"Enter a message to encrypt (! to quit)"< char letter;
cin>>letter;
while (letter!='!'){
if (letter=='k') cout<<"1 ";
assuming you choose option 1, after it is done encrypting it will print to screen "Enter a message to encrypt"
i need it to print "Enter 1 to encrypt, 2 to decrypt, 3 to quit"
it seems like i need to put the first statement in a loop as well, but i cant seem to figure out how to do it

2007-02-13 07:48:15 · 1 answers · asked by Alex P 2 in Computers & Internet Programming & Design

1 answers

Put a do...while loop around the whole thing somewhat like this:

int option;

do {
cout<<"Enter 1 to encrypt, 2 to decrypt, 3 to quit"< cin>>option;
if (option==1) {
cout<<"Enter a message to encrypt (! to quit)"< char letter;
cin>>letter;
while (letter!='!'){
if (letter=='k') cout<<"1 ";
... }
if (option==2) {
...
}
} while (option !=3);

2007-02-13 08:09:43 · answer #1 · answered by BigRez 6 · 1 0

fedest.com, questions and answers