Advertisement
007chill

Untitled

Oct 27th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3. public class Question11 {
  4. public static void main(String[] args)
  5. {
  6. Scanner keyboard = new Scanner(System.in);
  7. String password = "happy";
  8. String input = "empty";
  9. while (invalidPassword(input) != true)
  10. {
  11. System.out.println("Please enter a password: ");
  12. input = keyboard.nextLine();
  13. }
  14. System.out.println("Correct password.");
  15. }
  16.  
  17. public static boolean invalidPassword(String password)
  18. {
  19. boolean isTrue = false;
  20. if(password.equalsIgnoreCase("happy"))
  21. {
  22. isTrue=true;
  23. }
  24. return isTrue;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement