rahulbwn
- 8
- 0
i made a c++ login program but There is Problem occurred During Compairing a Given user name (string ) with a Pre defined String. Please give me some solution of it.
program
#include<iostream.h>
#include<conio.h>
#include<string.h>
class converter
{
public:
double i,j;
char m;
void acc()
{
cout<<"Enter ur choice(f for km and g for kg)";
cin>>m;
switch(m)
{
case 'f':
{
cout<<"Enter no. of km:";
cin>>i;
j=1000*i;
cout<<i<<" km is equal to "<<j<<" m";
break;
}
case 'g':
{
cout<<"Enter kg:";
cin>>i;
j=1000*i;
cout<<i<<" kg is equal to "<<j<<" gm";
break;
}
default:
{
cout<<"Wrong Choice";
}
}
}
};
class calculator
{
public:
double i,j,k;
char c;
void accept()
{
cout<<"Enter two no:";
cin>>i>>j;
cout<<"Enter ur choice(+,-,*,/):";
cin>>c;
switch(c)
{
case '+':
{
k=i+j;
cout<<"Sum is:"<<k;
break;
}
case '-':
{
k=i-j;
cout<<"sub. is:"<<k;
break;
}
case '*':
{
k=i*j;
cout<<"mul. is :"<<k;
break;
}
case '/':
{
k=i/j;
cout<<"div. is :"<<k;
break;
}
default:
{
cout<<"Wrong Choice";
}
}
}
};
void main()
{
clrscr();
int pass,pass1=9876,a,b=2,h;
char d,user[5],user1[]="rahul";
for(a=0;a<3;a++)
{
cout<<"Enter User Name:";
for(h=0;h<5;h++)
{
cin>>user[h];
}
cout<<"\nPlease Enter ur Password:";
cin>>pass;
if(pass==pass1&&strcmp(user,user1)==0)
{
cout<<"Enter ur choice (c for converter and v for calculator :";
cin>>d;
switch(d)
{
case 'c':
{
converter c1;
c1.acc();
break;
}
case 'v':
{
calculator c2;
c2.accept();
break;
}
default:
cout<<"Wrong choice";
}
break;
}
else
{
cout<<"wrong Password\n";
cout<<"You have "<<b<<" chances Remaining.\n";
if(b==0)
{
cout<<"\nSorry Your Account is Blocked.";
}
b--;
}
}
getch();
}
program
#include<iostream.h>
#include<conio.h>
#include<string.h>
class converter
{
public:
double i,j;
char m;
void acc()
{
cout<<"Enter ur choice(f for km and g for kg)";
cin>>m;
switch(m)
{
case 'f':
{
cout<<"Enter no. of km:";
cin>>i;
j=1000*i;
cout<<i<<" km is equal to "<<j<<" m";
break;
}
case 'g':
{
cout<<"Enter kg:";
cin>>i;
j=1000*i;
cout<<i<<" kg is equal to "<<j<<" gm";
break;
}
default:
{
cout<<"Wrong Choice";
}
}
}
};
class calculator
{
public:
double i,j,k;
char c;
void accept()
{
cout<<"Enter two no:";
cin>>i>>j;
cout<<"Enter ur choice(+,-,*,/):";
cin>>c;
switch(c)
{
case '+':
{
k=i+j;
cout<<"Sum is:"<<k;
break;
}
case '-':
{
k=i-j;
cout<<"sub. is:"<<k;
break;
}
case '*':
{
k=i*j;
cout<<"mul. is :"<<k;
break;
}
case '/':
{
k=i/j;
cout<<"div. is :"<<k;
break;
}
default:
{
cout<<"Wrong Choice";
}
}
}
};
void main()
{
clrscr();
int pass,pass1=9876,a,b=2,h;
char d,user[5],user1[]="rahul";
for(a=0;a<3;a++)
{
cout<<"Enter User Name:";
for(h=0;h<5;h++)
{
cin>>user[h];
}
cout<<"\nPlease Enter ur Password:";
cin>>pass;
if(pass==pass1&&strcmp(user,user1)==0)
{
cout<<"Enter ur choice (c for converter and v for calculator :";
cin>>d;
switch(d)
{
case 'c':
{
converter c1;
c1.acc();
break;
}
case 'v':
{
calculator c2;
c2.accept();
break;
}
default:
cout<<"Wrong choice";
}
break;
}
else
{
cout<<"wrong Password\n";
cout<<"You have "<<b<<" chances Remaining.\n";
if(b==0)
{
cout<<"\nSorry Your Account is Blocked.";
}
b--;
}
}
getch();
}