Advertisement
mrScarlett

passwordTask

Oct 2nd, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EventLoops{
  4. public static void main (String[] args){
  5. String userPassword;
  6. String password="computer";
  7. int wrongCount=0;
  8. Scanner userInput = new Scanner(System.in);
  9. System.out.print("Enter password");
  10.  
  11. while (!(userPassword = userInput.next()).equals(password)&&wrongCount!=3){
  12. System.out.println("You entered the wrong password");
  13. wrongCount+=1;
  14. }
  15. if (wrongCount ==3){
  16. System.out.println("Incorrect 3 times, you may not enter");
  17. }else{
  18. System.out.println("You may enter");
  19. }
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement