import java.io.*;
public class Password {
public static void main (
String[] args) {
int attempts = 0;
while (attempts < 3) {
System.out.println("Password");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String password = null;
try {
password = br.readLine();
} catch (IOException ioe) {
System.out.println("Error!");
System.exit(1);
}
if (password.equals("password")) {
System.out.println("Welcome user");
System.out.println(attempts + "failed attempts");
}
attempts = attempts + 1;
}
System.out.println("You don't know the password! GO AWAY!");
}
}
//don't use semicolon after while and replace == to string1.equals(string2) as you are comparing two strings.