I made a code to put in the user name id and password then create a new password; if the user name&password are wrong it should come up with a loop saying "invalid user id you can try ___ number of times. Please enter user id: " Then it starts over again so that part works in my code. But when making a new password it should not loop; it should only be 4 digits and can not be the same password of 1234; and this is where i am having a problem the 1234 works and says "Your password could not be changed." but when i put anything over or under 4 digits it doesnt do anything. it should say "Your password could not be changed." and exit but i'm not sure what i'm doing wrong can somebody please help me with this code and tell me how to fix it please!??
#include <iostream>
using namespace std;
int main()
{ //declaration
int pw;
int id;
int i=3;
do{
cout<<"enter six digit id: ";
cin>>id;
cout<<"enter four digit password: ";
cin>>pw;
if(123456==id && 1234==pw)
{
cout<<"Succesful login, please change password.;
cout<<"Enter new 4-digit password: ";
cin>>pw;
if ((pw >= 1000 && pw <= 9999 && pw != 1234))
{
cout<<"password has been changed."<< endl;
break;
}
else if (pw == 1234 && pw > 1000 && pw < 10000)
cout<<"password could not be changed."<<endl;
break;
}
else
{
cout<<"Invalid user id/password you can try: "<<i<<" more times."<<endl;
if (0==i)
cout<<"Login failed\n";
i--;
}
}while(i>=0);
system("pause");
}
#include <iostream>
using namespace std;
int main()
{ //declaration
int pw;
int id;
int i=3;
do{
cout<<"enter six digit id: ";
cin>>id;
cout<<"enter four digit password: ";
cin>>pw;
if(123456==id && 1234==pw)
{
cout<<"Succesful login, please change password.;
cout<<"Enter new 4-digit password: ";
cin>>pw;
if ((pw >= 1000 && pw <= 9999 && pw != 1234))
{
cout<<"password has been changed."<< endl;
break;
}
else if (pw == 1234 && pw > 1000 && pw < 10000)
cout<<"password could not be changed."<<endl;
break;
}
else
{
cout<<"Invalid user id/password you can try: "<<i<<" more times."<<endl;
if (0==i)
cout<<"Login failed\n";
i--;
}
}while(i>=0);
system("pause");
}