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
Why is it important to keep hand tools free of oil and grease?
Bezzdna [24]

Answer:

keeps it from rusting

Explanation:

5 0
3 years ago
Steam enters a steady-flow adiabatic nozzle with a low inlet velocity (assume ~0 m/s) as a saturated vapor at 6 MPa and expands
Sergio [31]
Yea bro I don’t really know
7 0
2 years ago
A gas within a piston–cylinder assembly undergoes an isothermal process at 400 K during which the change in entropy is 20.3 kJ/K
Mashcka [7]

Answer:

W= 8120 KJ

Explanation:

Given that

Process is isothermal ,it means that temperature of the gas will remain constant.

T₁=T₂ = 400 K

The change in the entropy given ΔS = 20.3 KJ/K

Lets take heat transfer is Q ,then entropy change can be written as

\Delta S=\dfrac{Q}{T}

Now by putting the values

20.3=\dfrac{Q}{400}

Q= 20.3 x 400 KJ

Q= 8120 KJ

The heat transfer ,Q= 8120 KJ

From first law of thermodynamics

Q = ΔU + W

ΔU =Change in the internal energy ,W=Work

Q=Heat transfer

For ideal gas ΔU  = m Cv ΔT]

At constant temperature process ,ΔT= 0

That is why ΔU  = 0

Q = ΔU + W

Q = 0+ W

Q=W= 8120 KJ

Work ,W= 8120 KJ

8 0
3 years ago
Decide whether the function is an exponential growth or exponential decay function, and find the constant percentage rate of gro
sasho [114]

Answer:

Just answered this to confirm my profile.

Explanation:

I dont have a clue, this is just to confirm my profile.

8 0
3 years ago
Which of the following is NOT true about hydraulic systems?
Dmitry [639]

Answer: The answer is D

D.In hydraulic systems, the operating temperatures must be kept between 170�F and 180°F 

Explanation:

The operating temperature for hydraulic systems is 140°F and below. Anything above this temperature is too high and will reduce the useful life of hydraulic fluid.

Most often problems associated with hydraulic systems are caused by fluid contaminated with particulate matter.

7 0
3 years ago
Other questions:
  • Q10: Technician A says that nearly all brands of scan tools will pull DTCs from the ABS
    14·1 answer
  • 2. The initially velocity of the box and truck is 60 mph. When the truck brakes such that the deceleration is constant it takes
    12·1 answer
  • Yasir is trying to build an energy-efficient wall and deciding what materials to use. How can he calculate the thermal resistanc
    6·1 answer
  • What is polarized electrical receptacle used for
    14·1 answer
  • A water tower that is 90 ft high provides water to a residential subdivision. The water main from the tower to the subdivision i
    10·1 answer
  • Which of the following is not one of the systems required to ensure the safe and correct operation of an engine?
    5·1 answer
  • A square isothermal chip is of width w 5 mm on a side and is mounted in a substrate such that its side and back surfaces are wel
    11·1 answer
  • Can someone answer plz!! It’s 24 points
    15·2 answers
  • A system of organization, people activities, informations, and resources involved in supplying a productor or service to a custo
    5·2 answers
  • When hermetic refrigerant motor-compressors are designed to operate continuously at currents greater than 156 percent of the rat
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!