Using the knowledge in computational language in JAVA it is possible to write the code that write a program whose input is: firstName middleName lastName, and whose output is: lastName, firstName middleInitial.
<h3>Writting the code:</h3>
<em>import java.util.Scanner;</em>
<em>import java.lang.*;</em>
<em>public class LabProgram{</em>
<em>public static void main(</em><em>String</em><em>[] args) {</em>
<em>String name;</em>
<em>String lastName="";</em>
<em>String firstName="";</em>
<em>char firstInitial=' ',middleInitial=' ';</em>
<em>int counter = 0;</em>
<em>Scanner input = new Scanner(System.in);</em>
<em>name = input.nextLine(); //read full name with spaces</em>
<em>int i;</em>
<em>for(i = name.length()-1;i>=0;i--){</em>
<em>if(name.charAt(i)==' '){</em>
<em>lastName = name.</em><em>substring</em><em>(i+1,name.length()); // find last name</em>
<em>break;</em>
<em>}</em>
<em>}</em>
<em />
<em>for(i = 0;i<name.length()-1;i++){</em>
<em>if(name.charAt(i)==' '){</em>
<em>firstName = name.substring(0, i); // find firstName</em>
<em>break;</em>
<em>}</em>
<em>}</em>
<em />
<em />
<em>for(i = 0 ;i<name.length();i++){</em>
<em>if(name.charAt(i)==' '){</em>
<em>counter</em><em>++; //count entered names(first,middle,last or first last only)</em>
<em>}</em>
<em>}</em>
<em>if(counter == 2){</em>
<em>for(i = 0 ;i<name.length();i++){</em>
<em>if(Character.</em><em>toUpperCase</em><em>(name.charAt(i)) == ' '){</em>
<em>middleInitial = Character.toUpperCase(name.charAt(i+1));//find the middle name initial character</em>
<em>break;</em>
<em>}</em>
<em>}</em>
<em>}</em>
<em>firstInitial = </em><em>Character</em><em>.toUpperCase(name.charAt(0)); //the first name initial character</em>
<em>if(counter == 2){</em>
<em>System.out.print(lastName+", "+firstName+" "+</em><em>middleInitial</em><em>+".");</em>
<em />
<em>}else{</em>
<em>System.out.print(lastName+", "+firstName);</em>
<em />
<em>}</em>
<em>}</em>
<em>}</em>
See more about JAVA at brainly.com/question/12975450
#SPJ1