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
3. Which of the following is an example of qualitative data?
ad-work [718]

Answer:

Number of Items

5 0
3 years ago
Thermosets burn upon heating. a)-True b)- false?
hram777 [196]

Answer:

true

Explanation:

True, there are several types of polymers, thermoplastics, thermosets and elastomers.

Thermosets are characterized by having a reticulated structure, so they have low elasticity and cannot be stretched when heated.

Because of the above, thermosetting polymers burn when heated.

5 0
3 years ago
The given family of functions is the general solution of the differential equation on the indicated interval.Find a member of th
Alja [10]

Answer:

Explanation:

y'''+y=0---(i)

General solution

y=c_1e^o^x+c_2\cos x +c_3 \sin x\\\\\Rightarrow y=c_1+c_2 \cos x+c_3 \sin x---(ii)\\\\y(\pi)=0\\\\\Rightarrow 0=c_1+c_2\cos (\pi)+c_3\sin (\pi)\\\\\Rightarrow c_1-c_2=0\\\\c_1=c_2---(iii)

y'=-c_2\cos x+c_3\cosx\\\\y'(\pi)=2\\\\\Rightarrow2=-c_2\sin(\pi)+c_3\cos(\pi)\\\\\Rightarrow-c_2(0)+c_3(-1)=2\\\\\Rightarrow c_3=-2\\\\y''-c_2\cos x -c_3\sin x\\\\y''(\pi)=-1\\\\\Rightarrow-1=-c_2 \cos (\pi)=c_3\sin(\pi)\\\\\Rightarrow-1=c_2-0\\\\\Rightarrow c_2=-1

in equation (iii)

c_1=c_2=-1

Therefore,

\large\boxed{y=-1-\cos x-2\sin x}

5 0
3 years ago
Argue the importance to society of incorporating green building into an engineer’s designs, with at least two examples.
klio [65]
It is important because now a days we all need help from engineers
3 0
3 years ago
Suppose the following two events occur at the same time: the Chicago Cubs win the World Series, and the workers who make Cubs me
Annette [7]

Answer:

the answer would be decrease decrease

3 0
3 years ago
Other questions:
  • What must engineers keep in mind so that their solutions will be appropriate? O abstract knowledge O context O scientists persev
    12·1 answer
  • What is the one change that golden expects to see in public transportation?
    12·1 answer
  • A vacuum gage connected to a tank reads 30 kPa at a location where the barometric reading is 755 mmHg. Determine the absolute pr
    14·1 answer
  • Write a program in C++ that can be used by a small theater to sell tickets for performances.The theater’s auditorium has 15 rows
    7·1 answer
  • Hot carbon dioxide exhaust gas at 1 atm is being cooled by flat plates. The gas at 220 °C flows in parallel over the upper and l
    15·1 answer
  • 2.44mW of incident 520 nm light is directed through a1 cm sample cuvette and 0.68 mW of Plight exits the sample what is the abso
    9·1 answer
  • Which of the following explains the main reason to cut a piece of wood on the outside of the measurement mark?
    13·1 answer
  • Which option identifies the concept represented in the following scenario?
    7·1 answer
  • Why is it important to follow the engineering design process before building a prototype
    13·1 answer
  • 1) Plastics that soften when heated,harden when cooled, and then can be heated and softened many times
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!