0

Just a few days ago I was working on a encrypting program that would take a character and convert it to the corresponding number. while working on it I found that you could input multiple letters and it would loop through all the letters and I can't figure out why it's not really a problem just trying to figure out what's going on....btw it is set to a loop at the beginning so you can keep entering more sentences to encrypt.

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    char Letter;
    int number;
    cout <<"please type your unencrypted sentence" << endl;
    cout <<"remeber to use commas to space your words" << endl;
    do{
    cin >> Letter;
        if(Letter == ('a')){
             number = 109;
             }
        if(Letter == ('b')){
             number = 100;
             }
        if(Letter == ('c')){
             number = 101;
             }
        if(Letter == ('d')){
             number = 119;
             }
        if(Letter == ('e')){
             number = 111;
             }
        if(Letter == ('f')){
             number = 110;
             }
        if(Letter == ('g')){
             number = 199;
             }
        if(Letter == ('e')){
             number = 190;
             }
        if(Letter == ('h')){
             number = 999;
             }
        if(Letter == ('i')){
             number = 991;
             }
        if(Letter == ('j')){
             number = 990;
             }
        if(Letter == ('k')){
             number = 900;
             }
        if(Letter == ('l')){
             number = 909;
             }
        if(Letter == ('m')){
             number = 901;
             }
        if(Letter == ('n')){
             number = 919;
             }
        if(Letter == ('o')){
             number = 910;
             }
        if(Letter == ('p')){
             number = 911;
             }
        if(Letter == ('q')){
             number = 191;
             }
        if(Letter == ('r')){
             number = 809;
             }
        if(Letter == ('s')){
             number = 800;
             }
        if(Letter == ('t')){
             number = 801;
             }
        if(Letter == ('u')){
             number = 819;
             }
        if(Letter == ('v')){
             number = 810;
             }
        if(Letter == ('w')){
             number = 811;
             }
        if(Letter == ('x')){
             number = 899;
             }
        if(Letter == ('y')){
             number = 890;
             }
        if(Letter == ('z')){
             number = 891;
             }
        if(Letter == (',')){
             number = 980;
             }
        if(Letter == ('.')){
             number = 989;
             }
         
    cout << number << ":";
    }while(number <= 1000);
    getch();
    return 0;
}
1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by gladtoplay5
0

LOL I'm stupid .... its because of the loop at the end it's returning back to the top and continuing with the rest of the characters

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.