Write a Java program that prompts the user for a single string, which represents a
person's name: first name and last name.
The program should:
• Accept all input from the console using the Scanner.nextLine() method.
• Store the input to a single String object named fullName.
• Determine the position of the space ( " " or ' ' ) separating the first and last name
and assign the position to an integer variable named spaceIndex.
• Hint: Use the indexOf() method to find the position of the space.
• Use spaceIndex to extract the substrings of the first name and last name, assigning
each to String objects named firstName and lastName.
• Hint: Use the substring() method to extract a substring from the original
string.
• Extract the first character (at position zero (0)) from firstName and assign it to a char
variable named initial.
• Hint: Use the charAt() method to extract the character from the string.
• Format the data obtained into an honorific for a doctor.
• Use string concatenation or System.out.printf() to produce the output.
• Write Java code to implement the above requirements. Ensure that the program
follows the given instructions precisely and produces the expected output format.
• Once you've completed the implementation, test your program with different inputs to
verify its correctness and ensure it produces the expected output format.