Advertisement
TheSTRIG

Untitled

Oct 30th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Latihan1DSendiri{
  4.     public static boolean isSafePassword (String password){
  5.         if(password.length() < 5){
  6.             return false;
  7.         } else {
  8.             int jumlahAngka = 0;
  9.             int jumlahUppercase = 0;
  10.        
  11.             for (int i = 0; i < password.length(); i++){
  12.                 char karakter = password.charAt(i);
  13.                 if(Character.isDigit(karakter)){
  14.                     jumlahAngka++;
  15.                 }
  16.                
  17.                 if(Character.isUpperCase(karakter)){
  18.                     jumlahUppercase++;
  19.                 }
  20.             }
  21.         return jumlahAngka >= 2 && jumlahUppercase >= 2;
  22.         }
  23.     }
  24.    
  25.     public static void main (String[] args){
  26.         Scanner scan = new Scanner(System.in);
  27.         System.out.println("====================================");
  28.         System.out.println("Program Verifikasi Kekuatan Password");
  29.         System.out.println("====================================");
  30.         System.out.print("Masukan password anda: ");
  31.         String password = scan.nextLine();
  32.        
  33.         /* ini pasti bener
  34.         System.out.println(isSafePassword(password));
  35.         */
  36.        
  37.         if(isSafePassword(password) = false){  
  38.             System.out.println("lemah");
  39.         } else {
  40.             System.out.println("strong");
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement