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 firstNamezero 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, PS
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, JRR
Ex: If the input is:
Fletch
the output is:
Fletch
Ex: If the input is:
Albus Percival Wulfric Brian Dumbledore
the output is:
Dumbledore, APWB
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
