dimanche 13 décembre 2020

How to take 3 random letters from first name , 2 from last name and phone number and 1 symbol from the given string 'specialChar'

public class testingstring {

   public static void main(String[] args) 
   {
       Scanner userInput = new Scanner (System.in) ;
    
       String specialChar = "!@#$%^&*()" ;
    
       System.out.println("Enter your first name: ");
       String firstName = userInput.next() ;
    
       System.out.println("Enter your last name: ") ;
       String lastName = userInput.next() ;
    
       System.out.println("Enter your phone number: ") ;
       String phoneNum = userInput.next() ;

   }
}

The program should randomly generate 8 characters long password as follows:

  1. 3 random letters from the first name
  2. 2 random letters from the last name
  3. 2 random digits from the mobile phone number
  4. 1 random character from the variable 'specialChar'



Aucun commentaire:

Enregistrer un commentaire