Create a program that receives a student's name as input and then outputs a three-character ID for thatstudent. This three-character ID would be used to create a longer, unique ID but that is not a part of thisparticular program.Prompt the user to enter a student's name. You can assume that the student's name will have either twoor three parts to it, i.e. it will either be first-name last-name or first-name middle-name last-name.The ID is created as follows. If the user enters a three partname, the ID number is created by takingtheir initials, i.e. the first character of each part of the name, converted to lower-case characters wherenecessary. For example, the name “David Robert Jones" would lead to an ID of drj.If the user enters a two-part name, the ID is again created by taking their initials, converted to lower-casecharacters where necessary, but this time substituting an “x" character for the missing middle name. Forexample, the name “Richard Starkey" would lead to an ID of rxs.All upper-case letters must be converted to lower-case in the ID.Your class must contain the following method:public StringcreateID(String input)This method receives the input name as a single String and returns the generated ID as a String.If the input string is not valid then this method should return the value null. The input is not valid if:It is null.It is empty.It does not contain either two or three parts.
Create a program that receives a student's name as input and then outputs a three-character ID for thatstudent. This three-character ID would be used to create a longer, unique ID but that is not a part of thisparticular program.Prompt the user to enter a student's name. You can assume that the student's name will have either twoor three parts to it, i.e. it will either be first-name last-name or first-name middle-name last-name.The ID is created as follows. If the user enters a three partname, the ID number is created by takingtheir initials, i.e. the first character of each part of the name, converted to lower-case characters wherenecessary. For example, the name “David Robert Jones" would lead to an ID of drj.If the user enters a two-part name, the ID is again created by taking their initials, converted to lower-casecharacters where necessary, but this time substituting an “x" character for the missing middle name. Forexample, the name “Richard Starkey" would lead to an ID of rxs.All upper-case letters must be converted to lower-case in the ID.Your class must contain the following method:public StringcreateID(String input)This method receives the input name as a single String and returns the generated ID as a String.If the input string is not valid then this method should return the value null. The input is not valid if:It is null.It is empty.It does not contain either two or three parts.
Step by step
Solved in 2 steps with 1 images