Nice and simply use a counter. Every time the password is entered make a variable++ until the variable is equal to 3. Then have an "if" statement before the password entry that checks if the variable is equal to or greater than 3.
So for example -
1 2 3 4 5 6 7 8 9 10
loop{
int counter;
if(counter is >= 3)
exit loop
enter password
if(password is correct)
dothiselse
counter++
}
continue = false
remainingPasswordAtemps = 3
do
{
Display instruction
Get username and password
If username and password are valid
{
continue = true
}
Else
{
--remainingPasswordAtemps
If remainingPasswordAtemps is zero
Exit
}
}while not continue
...