The program asks for password and you enter it, else you get 3 attempts and if you fail 3 times it locks (in theory).
Questions:
How should I write the while loop, now it just says "Line can't be resolved to a variable" and I don't know how to solve this.
The subtraction of attempts also doesn't work. How should I write it?
Here's the code:
import java.util.Scanner;
public class Application {
public static void main(String[] args) {
while(line != correctPass) {
String correctPass = "Java";
System.out.println("Enter the password");
Scanner input = new Scanner(System.in);
String line = input.nextLine();
if(line.equals(correctPass)) {
System.out.println("Wellcome back sir!");
break;
}
else {
int num = 3;
System.out.println("Wrong password, please try again! " + num + " attempts left!");
num = num - 1;
if(num == 0) {
System.out.println("System Locked!");
break;
}
}
}
}
}