Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

password verification, problem with password verify section

$
0
0
code compiles and runs but only goes to the password verification section if the user enters an incorrect password and needs to reenter a correct password. Tried an if/else statement and would not recognize the passwordVerify. Suggestions on how to correct so program continues to verification section after a correct password is entered the first time would be helpful. Thank you


import javax.swing.*;
	
   public class Password
   {
      public static void main (String[]args)
      {
         String passwordIn;
         String passwordVerify;
         int startLength;      
         boolean letterFound = false;           
         boolean digitFound = false;      
         boolean check = false;      
         
         passwordIn = JOptionPane.showInputDialog("Enter a Password:\nMore than 5 characters\nLess than 10 characters.\nContaining at least 1 letter and 1 number. ");
      	
         startLength = passwordIn.length();
      	  
         while(startLength < 6 || startLength > 10)
         {
            JOptionPane.showInputDialog("Your password does not meet the length requirements of:\nMore than 5 characters\nLess than 10 characters.\nPlease try again.");
            startLength = passwordIn.length();
         
            for(int i=0;i<passwordIn.length();i++)         
            {
               char s=passwordIn.charAt(i);          
            
               if(Character.isLetter(s))            
               {           
                  letterFound = true;            
               }
                              
               if(Character.isDigit(s))             
               {
                  digitFound = true;            
               }                                             
            }
                        
            if(letterFound == true &&  digitFound == true)         
            {         
               check=true;         
            }
            
            while(check == true) 
            {                            
               passwordVerify=JOptionPane.showInputDialog("Please enter your password again for verification.");
            
               if(!passwordVerify.equals(passwordIn))
               
               { 
                             
                  JOptionPane.showMessageDialog(null,"The program has successfully completed.");               	
               }
               else
               {
                  JOptionPane.showInputDialog("Your passwords do not match.\nPlease enter your password again to verify.");
               }   
            }
         }
         
         	  
      }
   }
 

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>