Advertisement
Shavit

P. 198 Ex. 7.58

Nov 16th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Password {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.        
  13.         char ch;
  14.         int uppercaseCounter = 0;
  15.         int lowercaseCounter = 0;
  16.         int chCounter = 0;
  17.        
  18.         System.out.println("Enter your password. End it with the symbol *");
  19.         ch = in.next().charAt(0);
  20.        
  21.         do
  22.         {
  23.             if(ch >= 65 && ch <= 90)
  24.                 uppercaseCounter++;
  25.             else if(ch >= 97 && ch <= 122)
  26.                 lowercaseCounter++;
  27.             chCounter++;
  28.            
  29.             ch = in.next().charAt(0);
  30.         }
  31.         while(ch != '*');
  32.    
  33.         if(uppercaseCounter > 0 && lowercaseCounter > 0 && chCounter > 5)
  34.             System.out.println("Your password is ok!");
  35.         else
  36.             System.out.println("Your password is not ok!");
  37.        
  38.         in.close();
  39.     }  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement