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;
}
}
}
}