Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class Passwords {
- public static void main(String[] args) {
- Scanner inputScanner = new Scanner(System.in);
- String lowercaseVowels = "aeiou", uppercaseVowels = "AEIOU";
- String lowercaseConsonants = "bcdfghjklmnpqrstvwxyz", uppercaseConsonants = "BCDFGHJKLMNPQRSTVWXYZ";
- System.out.println("Welcome to the username and password generator!");
- System.out.println("Please enter your first name:");
- String firstname = inputScanner.nextLine();
- String[] firstnames = firstname.split("");
- String first = firstnames[0];
- System.out.println("Please enter your last name:");
- String lastname = inputScanner.nextLine();
- String lastname1 = lastname + "s" + "s" + "s" + "s" + "s" + "s";
- String[] lastnames = lastname1.split("");
- String lastone = lastnames[0], lasttwo = lastnames[1], lastthree = lastnames[2], lastfour = lastnames[3], lastfive = lastnames[4], lastsix = lastnames[5], lastseven = lastnames[6];
- System.out.println("Please enter your favorite word:");
- String favword = inputScanner.nextLine();
- int num = (int) (Math.random() * 100);
- String username = first + lastone + lasttwo + lastthree + lastfour
- + lastfive + lastsix + lastseven + num;
- for (int i = 0; i < lowercaseVowels.length(); i++) {
- for (int k = 0; k < lowercaseConsonants.length(); k++) {
- username = username.replace(uppercaseVowels.charAt(i),
- lowercaseVowels.charAt(i));
- username = username.replace(uppercaseConsonants.charAt(k),
- lowercaseConsonants.charAt(k));
- }
- }
- System.out.println("Thanks " + firstname + ", your username is: "
- + username);
- String unencrypted = "aols", encrypted = "@01$";
- String firstname2 = firstname, lastname2 = lastname;
- for (int i = 0; i < unencrypted.length(); i++) {
- firstname = firstname.replace(unencrypted.charAt(i), encrypted.charAt(i));
- lastname = lastname.replace(unencrypted.charAt(i), encrypted.charAt(i));
- }
- int num2 = (int) (Math.random() * 100);
- String password1 = firstname + num2 + lastname;
- for (int i = 0; i < lowercaseVowels.length(); i++)
- for (int k = 0; k < lowercaseConsonants.length(); k++) {
- password1 = password1.replace(uppercaseVowels.charAt(i),
- lowercaseVowels.charAt(i));
- password1 = password1.replace(uppercaseConsonants.charAt(k),
- lowercaseConsonants.charAt(k));
- }
- System.out.println("Here are three suggested passwords for you to consider:");
- System.out.println(password1);
- String password2 = "" + firstname.charAt(0) + firstname.charAt(firstname.length() - 1)
- + lastname.charAt(0) + lastname.charAt(lastname.length() - 1) + favword.charAt(0)
- + favword.charAt(favword.length() - 1);
- System.out.println(password2);
- }
- }
Add Comment
Please, Sign In to add comment