Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EventLoops{
- public static void main (String[] args){
- String userPassword;
- String password="computer";
- int wrongCount=0;
- Scanner userInput = new Scanner(System.in);
- System.out.print("Enter password");
- while (!(userPassword = userInput.next()).equals(password)&&wrongCount!=3){
- System.out.println("You entered the wrong password");
- wrongCount+=1;
- }
- if (wrongCount ==3){
- System.out.println("Incorrect 3 times, you may not enter");
- }else{
- System.out.println("You may enter");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement