Caesar Cipher Code. I AM LOST

Okay so as the title suggest I am writing a caesar cipher. I am fully aware of what it does, but I am quite lost as to how to make it do what I want. I am not very good at programming. I knew absolutely nothing about it until 7 weeks ago, meaning this is my first programming class. Anyways I am only at part two of the program. It is the step where it ciphers the word i.e. if they type "Hello" in option 1, then choose 3 shifts, it would cout "ebiil". Anyways I am very lost, any help would be appreciated. Oh and as you may notice the code is VERY novice, that is because my teacher has told us to do it as so, only arrays, no strings, none of the fancy business. Here's the code:

#include <iostream>

using namespace std;

int main () {

int choice;
char word[140];
char new_word[140];
int Letter_Amount;
char Answer;
int shifts;
char alphabet[27] = {'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'};
char new_alphabet[27];


bool flag=false;
bool flag_2=false;
do{
cout << "Ceaser Cipher v2.0" << endl;
cout << "1. To input/modify input data" << endl;
cout << "2. To cipher a message" << endl;
cout << "3. To decipher a message" << endl;
cout << "4. To perform a statistical analysis of the text." << endl;
cout << "Press 0 to quit." << endl;
cout << "Please choose: ";
cin >> choice;

if(choice==0) cout <<"Now quitting..";

else if(choice==1){
if(flag_2==false){
cout << "Give input count: ";
cin >> Letter_Amount;
cout << "Please give text: ";
for (int i=0; i<Letter_Amount; i++){
cin >> word[i];
}
cout << endl;
}

else {
cout << "Are you sure you want to modify the input?" << endl;
cin >> Answer;
if(Answer=='n'){
cout << "Returning to the main menu..\n\n"; }
else if(Answer=='y'){
cout << "Give new input count: ";
cin >> Letter_Amount;
cout << "Please give new text: ";
for (int i=0; i< Letter_Amount; i++){
cin >> word[i];
}
}
else cout << "Please choose Y(es) or N(o).\n";
}

flag=true;
flag_2=true;
}

else if(choice==2){
if(flag){
cout << "Please choose the number of shifts you want: ";
cin >> shifts;
for(int i=0; i<26; i++){
if(i-shifts>=0){
new_alphabet[i]=alphabet[i-shifts];
}
else{
new_alphabet[i]=alphabet[26+i-shifts];
}
}
for(int i=0; i<Letter_Amount; i++){
for(int j=0; j<26;j++){
if(word[i]==alphabet[j]){
new_word[i]==new_alphabet[j];
}
}
}
cout << new_word;
}
else cout << "Please use option 1 before using this one.\n\n";
}

else if(choice==3){
if(flag){
cout << "Option 3 is still under progress.\n\n";
}
else cout << "Plese use option 1 before using this one.\n\n";
}

else if(choice==4){
if(flag){
cout << " Option 4 is still under progress.\n\n" << endl;
}
else cout << "Please use option 1 before using this one.\n\n";
}
}while(choice!=0);
return 0;}

What's this letter amount business?

Use getline to read the string and use the string's size() method to get the length.
I have to do it that way. My project has to run the same way as the professor's example, and that is what his does. Asks for the user to input how many letters are in the word. Then asks for the word.


Wait so what is the question... is something malfunctioning? I would suggest using some functions to seperate the functionality of the program, so at minimal one for encrypting and one for decrypting. This would perhaps better order the chaos of if/else statements.
Topic archived. No new replies allowed.