The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
*Please write code in both C and C+ language to be chosen as best answer. Please answer each part of the question with thorough explanation*
Consider the following program that is designed to perform Caesar encryption method.
Type, compile, run, and observe the output.
Is there any bug or deficiency concerning the solution?If yes what are they and how can be fixed?
Modify the program (code) such that it could shift the string by any number between 1 and 26.
Modify the program (code) such that the user can run it as many time as he/she wants.
You should provide digital and hard copy of your work.
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char **argv)
{
           string input;
           int count = 0, length ;
                     Â
           cout <<" Enter your phrase:"<<endl;
           getline (cin, input);
           length = (int) input.length ();
           for (count = 0; count < length; count++)
           {
                       if (isalpha (input [count]))
                       {                    Â
                                   for (int i = 0; i < 12; i++)
                                   {
                                               if (input [count] == 'z')
                                                           input [count] = 'a' ;
                                               else
                                                           input[count] ++;
                                   }
                       }
           }
           cout << " Results: \n" << input<<endl;                    Â
   system("PAUSE");
   return EXIT_SUCCESS;
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------