Answer:
import java.util.Scanner;
public class num3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Favorite color");
String word1 = in.next();
System.out.println("Enter Pet's name");
String word2 = in.next();
System.out.println("Enter a number");
int num = in.nextInt();
//Point One
System.out.println("You entered: "+word1+" "+word2+
" "+num);
//Point Two
String passwordOne = word1+"_"+word2;
String passwordTwo = num+word1+num;
System.out.println("First password: "+passwordOne);
System.out.println("Second password: "+passwordTwo);
//Point Three
int len_passwrdOne = passwordOne.length();
int len_passwrdTwo = passwordTwo.length();
System.out.println("Number of characters in "+passwordOne+" :" +
" "+len_passwrdOne);
System.out.println("Number of characters in "+passwordTwo+" :" +
" "+len_passwrdTwo);
}
}
Explanation:
- This question is solved using java programming language
- The scanner class is used to receive the three variables (Two string and one integer)
- Once the values have been received and stored in the respective variables (word1, word2 and num), Use different string concatenation to get the desired output as required by the question.
- String concatenation in Java is acheived with the plus (+) operator.