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
Do the coil resistances have any effect on the plots?
PolarNik [594]
Because of the skin depth effect, the current at high frequency tends to flow at very low depth from radius. Then at high frequency the effective cross section of the wire is narrower than at DC.

Fro example skin depth at 100 kHz is 0.206 mm (0.008”), a wire more thicker than AWG26 could be a waste of copper, better use a bunch of thin wire (Litz wire) to rise the Q factor.
8 0
3 years ago
the employer must comply with an employees or employee representative request to examine and copy abatement documents within
frez [133]
The employer must inform employees and their representatives of their right to examine and copy all abatement documents submitted to the Agency. ... The employer must comply with an employee's or employee representative's request to examine and copy abatement documents within 5 working days of receiving the request.
3 0
3 years ago
An escalator in a shopping center is designed to move 50 people, 75 kg each, at a constant speed of 0.6 m/s at 45° slope. Determ
kramer

Answer:

\dot E = 15602.842\,W

Explanation:

By an adequate application of the Principle of Energy Conservation, the escalator need energy to elevate from to the bottom to the top. Hence:

E = m_{total}\cdot g \cdot y

An expression for power needed is found by deriving the equation with respect to time:

\dot E = m_{total}\cdot g \cdot v_{y}

The minimum power is found by substituting known inputs:

\dot E = (50)\cdot (75\,kg) \cdot (9.807\,\frac{m}{s^{2}} )\cdot (0.6\,\frac{m}{s} )\cdot \sin 45^{\textdegree}

\dot E = 15602.842\,W

6 0
3 years ago
1. When working on charging systems, all of the fol-
andreyandreev [35.5K]

Answer:

c

Explanation:

You never want short system terminals

7 0
2 years ago
Please help me
Minchanka [31]

Answer:

The first step of the problem solving process is to identify and define the problem. The second step, which is to analyze the problem, involves gathering information, sorting through relevant and irrelevant information, and evaluating the source of the problem by asking the Five W's: who, what, where, when, and why.

7 0
3 years ago
Other questions:
  • A 0.2‐kg particle P is constrained to move along the vertical‐plane circular slot of radius r = 0.5 m and is confined to the slo
    5·1 answer
  • An inductor (L = 400 mH), a capacitor (C = 4.43 µF), and a resistor (R = 500 Ω) are connected in series. A 44.0-Hz AC generator
    11·1 answer
  • What is the basic of Architecture?​
    5·1 answer
  • Silicon carbide nanowires of diameter D = 15 nm can be grown onto a solid siliconcarbide surface by carefully depositing droplet
    13·1 answer
  • When would working with machinery be a common type of caught-in and caught-between<br> hazard?
    6·1 answer
  • An incompressible viscous fluid flows through a pipe with a flow rate of 1 mL/s. The pipe has a uniform diameter D0 and a length
    13·1 answer
  • Smith wants to get a job in network systems. Which major should he choose to give him the best chance of getting a job?
    14·2 answers
  • D. projectile
    13·1 answer
  • Define the term 'Computer​
    8·2 answers
  • I'll give a free brainliest
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!