Assignment brief:
You have been asked to develop an application that generates a password based upon a user’s date of birth and the length of their first name.

The password is made up of the first name in lower case and a number which is calculated as follows:
  • Length of name + Unicode of uppercase version of the first letter + sum of 2 digits in day + sum of 2digits in month + last 2 digits of the year.
  • If Xavier was born on 12th March 1990 (12/03/1990) then the password is xavier190
  • where 190 comes from: (6 (length of name) + 88 (Unicode of 'X') + 1+2 (12 broken into its digits 1 and 2) + 0 + 3 (03 broken into 0+3) + 90(from year))

Download code here

// Start of code---------------------
 import java.util.Scanner;

 
/* Usage notes:
 * Redistribution, alteration and use of this code with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * In no event shall the copyright owner be liable for any direct, indirect,
 * incidental, special, exemplary, or consequential damages arising in any
 * way out of the use of this software, even if advised of the possibility
 * of such damage.
 */

public class PasswordGenerator {

/*Brief description:

 * Read the first name and date of birth from user
 * Unique password is calculated as follows:
 * •    lowercase first name  
 * •   + stringsize of first name 
 * •    + Unicode of capital initial from first name 
 * •    + Sum of numbers in day of birth 
 * •    + numbers in year of birth
 */
   


    public static void main(String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
                      
        String firstname, dd, mm;
      
        int password, day, month, yy;
      
        System.out.println("Enter your First name" );
        firstname = keyboard.next();
      
        System.out.println("Enter dd of birth (Numeric digits only)");
        dd = keyboard.next();
      
        System.out.println("Enter mm of birth (Numeric digits only)");
        mm = keyboard.next();
      
        System.out.println("Enter yy of birth (Numeric digits only (ie: 80, 90))");
        yy = keyboard.nextInt();
      
        int stringSize = firstname.length();
      
        String lower = firstname.toLowerCase();
              
        char a = firstname.charAt(0);
      
        char upper = Character.toUpperCase(a);
      
        char ddletter1 = dd.charAt(0);
        char ddletter2 = dd.charAt(1);
      
        char mmletter1 = mm.charAt(0);
        char mmletter2 = mm.charAt(1);
      
        day = ddletter1 + ddletter2-96;
        month = mmletter1 + mmletter2-96;
      
        password = stringSize + upper + day + month + yy;
                  
        System.out.print("Your unique password is: " + lower + password);

    }

} // End of code---------------------