Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE DR JAVA PLEASE Define a complete Java class named Name that represents a per

ID: 3716760 • Letter: U

Question

USE DR JAVA PLEASE Define a complete Java class named Name that represents a person’s name. This class should contain 3 instance variables: one for the person’s first name, one for the last name, and one for the middle initial. The first and last name should be String values, and the middle initial a char. Define two constructor methods for this class. The first constructor should take 3 arguments – a person’s first name, middle initial, and last anem. The other constructor should accept just two arguments – a person’s first name and last name (because some people don’t have middle names). A method public String getNormalOrder() that returns a person’s name in the order with the first name followed by a space, then the middle initial, a period(.) and space, and then the last name. For example, “Stuart Q. Roberts” might be returned. If there is no middle name initial, then the first name would simply by followed by a space and the last name. A method public String getReversedOrder() that returns a person’s name in reverse order with the last name followed by a comma and space before the first name and initial. (e.g. “Roberts, Stuart Q.” would be returned. A method public String getInitials() that returns a person’s initial in the usual order, all in uppercase. For example, “SQR” might be returned. This file is Name.java

Explanation / Answer

---------------------------------------------------------------------------------------------

OUTPUT:

James H. Bond
Bond, James H.
JHB
Chandler . Bing
Bing, Chandler .
C B