Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class StringPassword {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner(System.in);
  7.  
  8.         System.out.print("Enter username: ");
  9.         String username = input.nextLine();
  10.  
  11.         System.out.print("Enter password: ");
  12.         String password = input.nextLine();
  13.  
  14.         validatePassword(password, username);
  15.  
  16.     }
  17.  
  18.     private static void validatePassword(String password, String username) {
  19.         boolean okay = true;
  20.  
  21.         if (password.length() < 8) {
  22.             okay = false;
  23.         }
  24.  
  25.         if (password.equals(username)) {
  26.             okay = false;
  27.         }
  28.  
  29.         if (okay == false) {
  30.             System.out.println("NOT OK");
  31.         } else {
  32.             System.out.print("OK");
  33.         }
  34.  
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement