Write a program that will generate a strong password derived

Write a program that will generate a strong password derived from the user’s input:

A sample run of the program:

Please enter your first name: Anthony

Pwd so far: An

Please enter your last name: sMith

Pwd so far: AnSm

Please enter your 2-digits favorite number: 23

Pwd so far: AnSm2^3

Please enter your City of Birth: greEnsBoro

Pwd so far: AnSm2^3Gr

Your 2-digits random number: 15

Your Final Pwd is: AnSm2^3Gr1.5

Note that the first Character is changed to uppercase and the second character is changed to lower case (in the name, last name, and city of birth) when added to the password. Note that the 2-digit favorite number is separated by a ‘^’ and the 2 digit random number is separated by a \'.\'

Solution

StrongPassword.java

import java.util.Random;
import java.util.Scanner;

public class StrongPassword {

   public static void main(String[] args) {
      
       //Declaring variables
       String firstname,lastname,birth_city,password=\"\";
       int fav_number,random_number;
  
       //Scanner class object is used to read the inputs entered by the user
       Scanner kb=new Scanner(System.in);
      
       //Getting the firstname entered by the user
       System.out.print(\"Please enter your first name: \");
       firstname=kb.next();
       //Converting the first character of the firstname to uppercase and concatenate to the password
       password=password+Character.toUpperCase(firstname.charAt(0));
       password=password+Character.toLowerCase(firstname.charAt(1));
       System.out.println(\"Pwd so far:\"+password);
      
       //Getting the lastname entered by the user
       System.out.print(\"\ Please enter your last name: \");
       lastname=kb.next();
       password=password+Character.toUpperCase(lastname.charAt(0));
       password=password+Character.toLowerCase(lastname.charAt(1));
       System.out.println(\"Pwd so far:\"+password);
      
       //Getting the favorite 2 digit number entered by the user
       System.out.print(\"\ Please enter your 2-digits favorite number: \");
       fav_number=kb.nextInt();
      
       password=password+Character.toUpperCase(String.valueOf(fav_number).charAt(0));
       password=password+\"^\";
       password=password+Character.toUpperCase(String.valueOf(fav_number).charAt(1));
       System.out.println(\"Pwd so far:\"+password);
      
       //Getting the cityname entered by the user
       System.out.print(\"\ Please enter your City of Birth: \");
       birth_city=kb.next();
       password=password+Character.toUpperCase(birth_city.charAt(0));
       password=password+Character.toLowerCase(birth_city.charAt(1));
       System.out.println(\"Pwd so far:\"+password);
      
       //creating the random class object
       Random rand=new Random();
      
       //Generating the two digit random number between 10 and 99(inclusive)
       random_number=rand.nextInt(91) + 10;
       System.out.println(\"\ Your 2-digits random number:\"+random_number);
       password=password+Character.toUpperCase(String.valueOf(random_number).charAt(0));
       password=password+\".\";
       password=password+Character.toUpperCase(String.valueOf(random_number).charAt(1));
      
       //Displaying the final password.
       System.out.println(\"Your Final Pwd is:\"+password);
      
      

   }

}

__________________________________________

Output:

Please enter your first name: Anthony
Pwd so far:An

Please enter your last name: sMith
Pwd so far:AnSm

Please enter your 2-digits favorite number: 23
Pwd so far:AnSm2^3

Please enter your City of Birth: greEnsBoro
Pwd so far:AnSm2^3Gr

Your 2-digits random number:39
Your Final Pwd is:AnSm2^3Gr3.9

______________________Thank You

Write a program that will generate a strong password derived from the user’s input: A sample run of the program: Please enter your first name: Anthony Pwd so fa
Write a program that will generate a strong password derived from the user’s input: A sample run of the program: Please enter your first name: Anthony Pwd so fa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site