Guest User

Untitled

a guest
Feb 9th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3.  
  4. public class Passwords {
  5. public static void main(String[] args) {
  6. Scanner inputScanner = new Scanner(System.in);
  7.  
  8. String lowercaseVowels = "aeiou", uppercaseVowels = "AEIOU";
  9. String lowercaseConsonants = "bcdfghjklmnpqrstvwxyz", uppercaseConsonants = "BCDFGHJKLMNPQRSTVWXYZ";
  10.  
  11. System.out.println("Welcome to the username and password generator!");
  12. System.out.println("Please enter your first name:");
  13. String firstname = inputScanner.nextLine();
  14. String[] firstnames = firstname.split("");
  15. String first = firstnames[0];
  16.  
  17. System.out.println("Please enter your last name:");
  18. String lastname = inputScanner.nextLine();
  19. String lastname1 = lastname + "s" + "s" + "s" + "s" + "s" + "s";
  20. String[] lastnames = lastname1.split("");
  21. String lastone = lastnames[0], lasttwo = lastnames[1], lastthree = lastnames[2], lastfour = lastnames[3], lastfive = lastnames[4], lastsix = lastnames[5], lastseven = lastnames[6];
  22.  
  23. System.out.println("Please enter your favorite word:");
  24. String favword = inputScanner.nextLine();
  25.  
  26. int num = (int) (Math.random() * 100);
  27. String username = first + lastone + lasttwo + lastthree + lastfour
  28. + lastfive + lastsix + lastseven + num;
  29. for (int i = 0; i < lowercaseVowels.length(); i++) {
  30. for (int k = 0; k < lowercaseConsonants.length(); k++) {
  31. username = username.replace(uppercaseVowels.charAt(i),
  32. lowercaseVowels.charAt(i));
  33. username = username.replace(uppercaseConsonants.charAt(k),
  34. lowercaseConsonants.charAt(k));
  35. }
  36. }
  37. System.out.println("Thanks " + firstname + ", your username is: "
  38. + username);
  39.  
  40. String unencrypted = "aols", encrypted = "@01$";
  41. String firstname2 = firstname, lastname2 = lastname;
  42. for (int i = 0; i < unencrypted.length(); i++) {
  43. firstname = firstname.replace(unencrypted.charAt(i), encrypted.charAt(i));
  44. lastname = lastname.replace(unencrypted.charAt(i), encrypted.charAt(i));
  45. }
  46. int num2 = (int) (Math.random() * 100);
  47. String password1 = firstname + num2 + lastname;
  48. for (int i = 0; i < lowercaseVowels.length(); i++)
  49. for (int k = 0; k < lowercaseConsonants.length(); k++) {
  50. password1 = password1.replace(uppercaseVowels.charAt(i),
  51. lowercaseVowels.charAt(i));
  52. password1 = password1.replace(uppercaseConsonants.charAt(k),
  53. lowercaseConsonants.charAt(k));
  54. }
  55.  
  56. System.out.println("Here are three suggested passwords for you to consider:");
  57. System.out.println(password1);
  58.  
  59. String password2 = "" + firstname.charAt(0) + firstname.charAt(firstname.length() - 1)
  60. + lastname.charAt(0) + lastname.charAt(lastname.length() - 1) + favword.charAt(0)
  61. + favword.charAt(favword.length() - 1);
  62.  
  63.  
  64. System.out.println(password2);
  65.  
  66. }
  67. }
Add Comment
Please, Sign In to add comment