Question
Define a complete Java class named Name that represents a persons name. This class should contain 3 instance variables: one for the persons first name,
Define a complete Java class named Name that represents a persons name. This class should contain 3 instance variables: one for the persons 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 persons first name, middle initial, and last anem. The other constructor should accept just two arguments a persons first name and last name (because some people dont have middle names). A method public String getNormalOrder() that returns a persons 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 persons 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 persons initial in the usual order, all in uppercase. For example, SQR might be returned. This file is Name.java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started