Sunday, August 2, 2009

Need help with a c++ program?

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%26lt;%26lt;"Enter 1 to encrypt, 2 to decrypt, 3 to quit"%26lt;%26lt;endl;


cin%26gt;%26gt;option;


while (option!=3) {


if (option==1) {


cout%26lt;%26lt;"Enter a message to encrypt (! to quit)"%26lt;%26lt;endl;


char letter;


cin%26gt;%26gt;letter;


while (letter!='!'){


if (letter=='k') cout%26lt;%26lt;"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

Need help with a c++ program?
Put a do...while loop around the whole thing somewhat like this:





int option;





do {


cout%26lt;%26lt;"Enter 1 to encrypt, 2 to decrypt, 3 to quit"%26lt;%26lt;endl;


cin%26gt;%26gt;option;


if (option==1) {


cout%26lt;%26lt;"Enter a message to encrypt (! to quit)"%26lt;%26lt;endl;


char letter;


cin%26gt;%26gt;letter;


while (letter!='!'){


if (letter=='k') cout%26lt;%26lt;"1 ";


... }


if (option==2) {


...


}


} while (option !=3);


No comments:

Post a Comment