Question: Write a function named getName with return type of string. Inside this function: Using a suitable message, ask the player for the name of the
Write a function named getName with return type of string. Inside this function:
Using a suitable message, ask the player for the name of the player. The name may have
multiple words.
Only alphabets AZ or az and whitespaces are permitted in the account name.
o If the player enters any other characters in the name, you need to generate an
error message and ask for the name again.
o Your program must keep on asking the player to enter the name until the player
enters it correctly.
The player may type the name in either uppercase or lowercase, but you need to convert
every initial to uppercase and every other alphabet to lowercase.
If the players name contains either Senior or Junior at the end as suffix, then convert to
that suffix into shortcut Sr or Jr Also add comma before Sr and Jr
o For example, Bill Gates Senior should be Bill Gates, Sr and Bill Gates Junior
should be Bill Gates, Jrwithout quotes
This function needs to return the name of the player and will be called from the main
function.
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
