1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Scilla [17]
3 years ago
8

1. Create a class called Name that represents a person's name. The class should have fields named firstName representing the per

son's first name, lastName representing their last name, and middleInitial representing their middle initial (a single character). Your class should contain only fields for now.
2. Add two new methods to the Name class:

public String getNormalOrder()
Returns the person's name in normal order, with the first name followed by the middle initial and last name. For example, if the first name is "John", the middle initial is 'Q', and the last name is "Public", this method returns "John Q. Public".

public String getReverseOrder()
Returns the person's name in reverse order, with the last name preceding the first name and middle initial. For example, if the first name is "John", the middle initial is 'Q', and the last name is "Public", this method returns "Public, John Q.".

(You don't need to write the class header or declare the fields; assume that this is already done for you. Just write your two methods' complete code in the box provided.)
Engineering
2 answers:
beks73 [17]3 years ago
8 0

Answer: Jhon Greenheart

Explanation:

attashe74 [19]3 years ago
4 0

ANSWER:

<u>( 1 )</u><em><u>.</u></em>

<em><u /></em>

public class Name{       //header declaration for the class <em>Name</em>    

   /*

<em>    Declare all necessary fields.</em>

   The first and last names of the person are string variables.

   Hence they are of type String.

   The middle initial of the person is a single character.

   Hence it is of type char.

   */

    String firstName;     // <em>person's first name called firstName</em>

    String lastName;      // <em>person's last name called lastName</em>

    char middleInitial;    // <em>person's middle initial called middleInitial</em>

}

==========================================================

<u>( 2 )</u>

/*

Method getNormalOrder() is declared as follows.

It returns the person's name in normal order with first name

followed by the middle initial and last name.

*/

public String getNormalOrder(){      

    // concatenate the firstName, middleInitial and lastName and return the

   // result.

    return this.firstName + " " + this.middleInitial + ". " + this.lastName;

}

/*

Method getReverseOrder() is declared as follows.

It returns the person's name with the last name

followed by the first name and middle initial.

*/

public String getReverseOrder(){

   // concatenate the lastName, lastName and middleInitial  and return the

   // result.

   return this.lastName + " " + this.firstName + " " + this.middleInitial + ".";

}

EXPLANATION:

The above code has been written in Java.

The code contains comments that explain every part of the code. Please go through the comments carefully for a better understanding of the code.

<em>Special note: </em>

i. Concatenation which means joining strings together, is done in Java using the + operator.

ii. The this keyword used in the two methods is optional. It is just used to reference to the instance variables - firstName, lastName and middleInitial - of the object.

<em>Hope this helps!</em>

You might be interested in
PROBLEM IN PICTURE HELP ME DEAR GODDDDDD UGHHH NONONO I HAVE 2 MINUTES TO FINISH THIS ❕❗️❕❗️❗️❕❕❕❕❗️❕❕❗️❕❗️❗️❗️❕‼️‼️‼️‼️❗️‼️❗️
Elan Coil [88]
Thx :) so much :))))))
4 0
3 years ago
Read 2 more answers
9. Cigarette smoking is dangerous to one's health. Which of the following is the
Alla [95]
C.nicotine
The worse compound
5 0
3 years ago
Read 2 more answers
An automobile having a mass of 1100 kg initially moves along a level highway at 120 km/h relative to the highway. It then climbs
soldier1979 [14.2K]

Answer:

-6111.11\ \text{kJ}

863.28\ \text{kJ}

Explanation:

m = Mass of automobile = 1100 kg

v = Velocity of car = 120 km/h = \dfrac{120}{3.6}\ \text{m/s}

h = Height of hill = 80 m

g = Acceleration due to gravity = 9.81\ \text{m/s}^2

Change in kinetic energy

KE=\dfrac{1}{2}m(u^2-v^2)\\\Rightarrow KE=\dfrac{1}{2}\times 1100\times (0-(\dfrac{120}{3.6})^2)\\\Rightarrow KE=-611111.11\ \text{J}

Change in kinetic energy is -6111.11\ \text{kJ}

Change in potential energy is given by

PE=mgh\\\Rightarrow PE=1100\times 9.81\times 80\\\Rightarrow PE=863280\ \text{J}

The change in potential energy is 863.28\ \text{kJ}.

8 0
3 years ago
Which of the following waste characteristic is considered to be hazardous:
Lynna [10]

Answer:

D) all of the above

Explanation:

8 0
4 years ago
What does CPU stand for? computer processing unit central programming unit central processing unit computer programming unit
Harman [31]
Central processing unit
6 0
3 years ago
Read 2 more answers
Other questions:
  • 6.28 A six-lane freeway (three lanes in each direction) in rolling terrain has 10-ft lanes and obstructions 4 ft from the right
    11·1 answer
  • Question 2 (Multiple Choice Worth 3 points)
    11·1 answer
  • A circuit has a source voltage of 15V and two resistors in series with a total resistance of 4000Ω .If RI has a potential drop o
    7·1 answer
  • You are reassembling a gearbox. The output
    9·1 answer
  • The Greek alphabet has 24 distinct lowercase letters. How many bits are needed to be able to encode any single lowercase Greek l
    9·1 answer
  • What is the essence of the Central park and it impact in New York?​
    7·1 answer
  • Determine if the fluid is satisfied​
    10·1 answer
  • g Calculate a better value for the convection coefficient using resources from heat transfer. Assume forced convection of the ai
    8·1 answer
  • Which of the following is not used for setting out right angles
    13·1 answer
  • Which statement is equivalent to the following? x = x * 2; x = x * x; x * 2; x *= 2; None of these
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!