JAVA 49
Jaba Guest on 10th January 2019 07:05:04 PM
  1. public class HelloWorld{
  2.  
  3.  
  4.     public static boolean lengthCheck(String input) {
  5.         if (input.length() >= 6 && input.length() < 11){
  6.             return true;
  7.         }
  8.         return false;
  9.     }
  10.    
  11.     public static boolean symbolCheck(String input){
  12.         if (input.matches("[a-zA-Z0-9]*")) {
  13.             return true;
  14.         }
  15.         return false;
  16.     }
  17.    
  18.     public static boolean digitCheck(String input){
  19.         input = input.replaceAll("[^0-9]","");
  20.         if (input.length() >= 2){
  21.             return true;
  22.         }
  23.         return false;
  24.     }
  25.    
  26.     public static void testPassword(String input){
  27.         boolean secure = false;
  28.         if (lengthCheck(input)) {
  29.             secure = true;
  30.         } else {
  31.             System.out.println("Password must be between 6 and 10 characters");
  32.             secure = false;
  33.         }
  34.         if (symbolCheck(input)) {
  35.             secure = true;
  36.         } else {
  37.             System.out.println("Password must consist only of letters and digits");
  38.             secure = false;
  39.         }
  40.         if (digitCheck(input)) {
  41.             secure = true;
  42.         } else {
  43.             System.out.println("Password must have at least 2 digits");
  44.             secure = false;
  45.         }
  46.         if (secure == true) System.out.println("Password is valid");
  47.         return;
  48.     }
  49.    
  50.      public static void main(String []args){
  51.        
  52.         String testPass = "Pa$s$s";
  53.         testPassword(testPass);
  54.        
  55.      }
  56. }

RSO cPaste е място за публикуване на код или текст за по-лесно отстраняване на грешки.

Влез или се Регистрай за да редактираш, изтриваш или преглеждаш хронология на твоето публикувано съдържание

Необработен текст

Влез или се Регистрирай за да редактираш или задържиш това съдържание.