In this step, we will take input from the user and display the number of Unicode code points present in the given text range.
try {
Scanner sc = new Scanner(System.in); // Scanner class object to take user input
System.out.println("Enter a character sequence: ");
CharSequence seq = sc.nextLine(); // take user input sequence
System.out.println("Enter the starting index of the text range: ");
int beginIndex = sc.nextInt(); // take user input begin index
System.out.println("Enter the end index of the text range: ");
int endIndex = sc.nextInt(); // take user input end index
int count = Character.codePointCount(seq, beginIndex, endIndex); // count code points
System.out.println("Count of code points: " + count);
} catch (Exception e) {
System.out.println("Invalid input");
}