Answer:
import java.util.Random;
import java.util.Scanner;
public class num14 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Your first Name");
String firstName = in.next();
System.out.println("Enter Your Last Name");
String lastName = in.next();
char firstLetter = firstName.charAt(0);
String firstFiveLetters = lastName.substring(0,5);
System.out.print(firstLetter+firstFiveLetters);
Random rand = new Random();
int randomNum = rand.nextInt(100)+10;
System.out.println(randomNum);
}
}
Step-by-step explanation:
- Using Java programming language
- Import Scanner class to receive user input and Random class to generate random number
- Prompt user for first and last name separately and store in variables firstName and lastName.
- Extract the first character of the firstname char firstLetter = firstName.charAt(0);
- Extract the first five characters of the last name String firstFiveLetters = lastName.substring(0,5);
- Concatenate the two extracted values and output
- Generate a random number between 10 and 99 and output.
- Observe that the random number utilizes a non-inclusive upperbound. that is rand.nextInt(100) will generate numbers from 0-99. We add 10 to this value to ensure it is between 10-99