How to stop access to program if login is failed, like after the third try i attempt, stop the entire program( make the next line appear only if login is successful ) . Cause my current program still works, after 3 try of failed attempt of logging in
string userID, password; // For login
const string stdUserID="test123";
const string stdPassword="test1234";
int i=0;
cout<<"Welcome to xxx Calculator"<<endl;
cout <<"----------Login Screen------------\n"; //For login
while ( i < 3 )
{
cout<<"To use xxx Calculator, please login !"<<endl;
cout <<"Please enter your userID:\t";
cin>>userID;
cout <<"Please enter your password:\t";
cin>>password;
if (userID.compare (stdUserID) ==0 && password.compare (stdPassword) ==0 )
{
system("COLOR 5");
printf("Login successful ! \n");
break; // exit loop after display welcome message
}
else
{
cout <<"You have entered an invalid user ID or password , please try again \n" ;
i++;
}
}
if (i==3)
cout <<"\nYou have reached maximum number of trials. Access Denied! \n" ;
while(loop=='Y' || loop=='y') // how to ensure that this part do not appear if there is failed attempt in logging in
{
cout <<"Please enter the ultimate tensile strength (UTS) of material needed ( highest 1000 ): " ;
cin >>strength;
if (i==3) // enters here at failed attempt
{
cout <<"\nYou have reached maximum number of trials. Access Denied! \n" ;
}
else // which means it doesnt enter here
{
while(loop=='Y' || loop=='y') // how to ensure that this part do not appear if there is failed attempt in logging in
}