Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you change the code below to (do-loop) format please #include using namespace std; int main() { // Get command choice cout < < Welcome
Can you change the code below to (do-loop) format please #includeusing namespace std; int main() { // Get command choice cout << "Welcome to Caesar's Cipher 2.0 " << " 1) Encode using classic algorithm " << " 2) Decode using classic algorithm " << " 3) Encode using improved algorithm " << " 4) Decode using improved algorithm " << "Enter command [1..4]: "; int command; cin >> command; // Get shift value int shift = 0; cout << "Enter shift value: "; cin >> shift; // Read user input cout << "Enter message to encode/decode: "; char input = ' '; char output = ' '; // Encode using classic algorithm if (command == 1) { cin.get(input); while (input != '.') { // Check input letter is between [A..Z] if ((input >= 'A') && (input <= 'Z')) { // Shift left for encode output = input - shift; if (output < 'A') output += 26; } // Print any spaces that occur else if (input == ' ') output = ' '; // Print results cout << output; cin.get(input); } } // Decode using classic algorithm else if (command == 2) { cin.get(input); while (input != '.') { // Check input letter is between [A..Z] if ((input >= 'A') && (input <= 'Z')) { // Shift right for decode output = input + shift; if (output > 'Z') output -= 26; } // Print any spaces that occur else if (input == ' ') output = ' '; // Print results cout << output; cin.get(input); } } // Encode using improved algorithm else if (command == 3) { cin.get(input); while (input != '.') { // Check input letter is between [A..Z] if ((input >= 'A') && (input <= 'Z')) { // Shift left for encode output = input - shift; if (output < 'A') output += 26; } // Print any spaces that occur else if (input == ' ') output = ' '; // Update shift value with improved algorithm shift = (shift % 25) + 1; // Print results cout << output; cin.get(input); } } // Decode using improved algorithm else if (command == 4) { cin.get(input); while (input != '.') { // Check input letter is between [A..Z] if ((input >= 'A') && (input <= 'Z')) { // Shift right for decode output = input + shift; if (output > 'Z') output -= 26; } // Print any spaces that occur else if (input == ' ') output = ' '; // Update shift value with improved algorithm shift = (shift % 25) + 1; // Print results cout << output; cin.get(input); } } cout << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started