I am trying to run this code and when I enter the user input of "nfc123" it prints Door Unlocked although then It returns to the start and wants me to Unlock the Door again. I would like it to continue and ask me if I would like to Lock the Door.
#include <string>
#include <iostream>
int main( int, char ** )
{
std::string input;
while( true )
{
std::cout << "Unlock Door Code: " << std::endl;
std::cin >> input;
if( input == "nfc123" )
{
std::cout << "Door Unlocked" << std::endl;
continue;
}
else if( input == "end" )
{
break;
}
else
{
std::cout << "Wrong Code: " << input << std::endl;
}
}
std::string input2;
while( true )
{
std::cout << "Lock Door Code: " << std::endl;
std::cin >> input2;
if( input2 == "nfc123" )
{
std::cout << "Door Locked" << std::endl;
}
else if( input2 == "end" )
{
break;
}
else
{
std::cout << "Wrong Code: " << input2 << std::endl;
}
}
return 0;
}