Question: Many documents use a speMany documents use a specific format for a person's name. Write a program that reads a persor's name in the following

Many documents use a speMany documents use a specific format for a person's name. Write a program that reads a persor's name in the following format:
[optional firstName][zero or more middle names] lastName (in one line)
and outputs the person's name in the following format:
lastName, [name initials with dots between them]
Note that there should be no comma after the last name if the full name only had one part. This should work for a name with one or more
parts and assume that the last part is the last name.
Ex. If the input is:
Pat Silly Doe
the output is:
Doe, P.S.
Ex. If the input is:
Julia Clark
the output is:
Clark, J.
Ex: If the input is:
John Ronald Reuel Tolkien
the output is:
Tolkien, J.R.R.
Ex: If the input is:
Fletch
the output is:
Fletch
Ex: If the input is:
Albus Percival Wulfric Brian Dumbledore
the output is:
Dumbledore, A.P.W.B.
Many documents use a speMany documents use a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!