WriteacompleteJavaprograminasourcefiletobenamedAssignment3.java.Theprogramaskstheuserfortheirfullname(firstmiddlelast-usingnextLinemethod)asonestringinanycombinationofupp...
Write a complete Java program in a source file to be named Assignment3.java.
The program asks the user for their full name (first middle last-using nextLine method) as one string in any combination of upper and lower case. Your task is to output the name in the following variations:
• Print just the initials in upper case letters
• Print the last name in upper case followed by a comma and the first name in lower case with the first letter capitalized and the middle initial capitalized followed by a period
• Print the last name comma first name and middle name – all names with first letter capitalized.
Note: Your program has to check for middle name and if the user does not have a middle name your program has to print the variations without the middle name. See the sample output below
Important: You will not get points if you do not read the string as one line (Use scan.nextLine()). You cannot use the Scanner class for extracting different parts of the name. You have to use the methods in class String
Here is the output your program should produce when the user enters the string shown in bold:
Sample Output: (the user enters the string shown in bold)
Sample output 1:
What are your first, middle, and last names?
david john smith
Your initials are: DJS
Variation one: SMITH, David J.
Variation two: Smith, David John
Sample output 2:
What are your first, middle and last names?
Faye Navabi
Your initials are: FN
Variation One: NAVABI, Faye
Variation Two: Navabi, Faye
Sample output 3:
What are your first, middle and last names?
Johnson
Wrong. Please enter your names properly.
这个程序该怎么写呢,谢谢!
展开