Thread: may i ask for a flavour...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    Unhappy may i ask for a flavour...

    sorry everybody...can u help me to change the programm from char to string??? cos the program typing with space will get the error...so...pls help...thanks

    #include<iostream.h>

    class Erypt
    {
    private:
    char Act;
    char Enc;
    public:
    Erypt(char,char);

    char getactual()
    {
    return Act;
    }
    char getencrypt()
    {
    return Enc;
    }
    void table();
    void menu();

    };

    Erypt ::Erypt(char a,char e)
    {
    Act = a;
    Enc = e;
    }


    void Erypt:: table()
    {
    cout<<" Actual Value = "<< getactual();
    cout<<"\t Encryption Value = "<<getencrypt()<<endl;
    }



    void menu()
    {
    cout<<"\n\n\n\n\n";
    cout<<"\t\t\t <1>. ENCRYPTION \n";
    cout<<"\t\t\t <2>. DECRYPTION \n";
    cout<<"\t\t\t <3>. TABLE ENCRYPTION \n";
    cout<<"\t\t\t <4>. QUIT \n";

    }

    void menu1()
    {
    cout<<"\n\n";
    cout<<"\t\t\t<1>. DIGIT "<<endl;
    cout<<"\t\t\t<2>. UPPER LETTER"<<endl;
    cout<<"\t\t\t<3>. LOWER LETTER"<<endl;
    cout<<"\t\t\t<4>. NOTATION"<<endl;
    }


    void main()
    {


    Erypt table[84]=
    {
    Erypt('0','+'),Erypt('1','*'),Erypt('2','$'),Erypt ('3','#'),Erypt('4','^'),Erypt('5','@'),
    Erypt('6','&'),Erypt('7',')'),Erypt('8','('),Erypt ('9','!'),Erypt('A','~'),Erypt('B','`'),
    Erypt('C','-'),Erypt('D','}'),Erypt('E','?'),Erypt('F',']'),Erypt('G','"'),Erypt('H','{'),
    Erypt('I','['),Erypt('J','%'),Erypt('K','='),Erypt('L','|'),Er ypt('M','1'),Erypt('N','9'),
    Erypt('O','5'),Erypt('P','6'),Erypt('Q','.'),Erypt ('R','-'),Erypt('S','2'),Erypt('T','3'),
    Erypt('U','4'),Erypt('V','7'),Erypt('W','0'),Erypt ('X','8'),Erypt('Y','/'),Erypt('Z',','),
    Erypt('a','p'),Erypt('b','o'),Erypt('c','i'),Erypt ('d','u'),Erypt('e','y'),Erypt('f','t'),
    Erypt('g','r'),Erypt('h','e'),Erypt('i','w'),Erypt ('j','q'),Erypt('k','a'),Erypt('l','s'),
    Erypt('m','d'),Erypt('n','f'),Erypt('o','g'),Erypt ('p','h'),Erypt('q','j'),Erypt('r','k'),
    Erypt('s','l'),Erypt('t','z'),Erypt('u','x'),Erypt ('v','c'),Erypt('w','v'),Erypt('x','b'),
    Erypt('y','n'),Erypt('z','m'),Erypt('!','|'),Erypt ('@','+'),Erypt('#','-'),Erypt('$',')'),
    Erypt('%','('),Erypt('^','*'),Erypt('&','^'),Erypt ('*','^'),Erypt('(','%'),Erypt(')','!'),
    Erypt('-','@'),Erypt('+','{'),Erypt('|','}'),Erypt('{',':' ),Erypt('}',';'),Erypt('[','.'),
    Erypt('"','Q'),Erypt('<','W'),Erypt('>','E'),Erypt (',','R'),Erypt('?','T'),Erypt('/','Y')};
    int ch,ch2;

    while(true){
    menu();
    cout<<"\n\t\t\t Please enter your choice(1-4) : ";
    cin>>ch;
    switch(ch)
    {
    case 1 : {
    char word[50]="";
    char codes[50]="";


    cout<<"\n Please enter the codes :";
    cin>>word;
    int j,i=0;
    while(word[i]!='\0')
    {
    for(j=0;j<84;j++)
    {
    if(word[i]==table[j].getactual())
    {
    codes[i]=table[j].getencrypt();
    i++;
    }
    }

    }
    cout<<"\n The Encryption of "<<word;
    cout<<" is "<<codes<<endl;

    }

    break;
    case 2 : {
    char word[50]="";
    char codes[50]="";


    cout<<"\n Please enter code for decryption :";
    cin>>word;
    int j,i=0;
    while(word[i]!='\0')
    {
    for(j=0;j<84;j++)
    {
    if(word[i]==table[j].getencrypt())
    {
    codes[i]=table[j].getactual();
    i++;
    }
    }

    }
    cout<<"\n The Decryption of "<<word;
    cout<<" is "<<codes<<endl;

    }
    break;
    case 3 :
    {
    menu1();
    cout<<"\n\t\t\tEnter your choice : ";
    cin>>ch2;
    if(ch2==1)
    {
    for(int i=0;i<10;i++)
    table[i].table();
    cout<<endl;
    }
    else if(ch2==2)
    {
    for(int i=10;i<36;i++)
    table[i].table();
    cout<<endl;
    }
    else if(ch2==3)
    {
    for(int i=36;i<62;i++)
    table[i].table();
    cout<<endl;
    }
    else if(ch2==4)
    {
    for(int i=62;i<84;i++)
    table[i].table();
    cout<<endl;
    }
    else
    cout<<"Invalid Choice!"<<endl;
    }
    break;
    case 4:
    {
    cout << " Thanks!\n";

    return;
    }
    default:
    {
    cout << "\n Invalid Choice!!\n ";
    break;
    }
    }
    }
    }

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Did you meant to say flavour? or favour?

    If the former then Rasberry Ripple......

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Read this then EDIT your post to make your code presentable.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    LOL, some typos are funny
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM