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 1: A catchment has the following Horton’s infiltration parameters: f0=280 mm/hr, fc=25 mm/hr and k = 2.5 hr-1 . For the
harkovskaia [24]

Answer:

Ponding will occur in 40mins

Explanation:

We say that the infiltration rate is the velocity or speed at which water enters into the soil. This often times is measured by the depth (in mm) of the water layer that can enter the soil in one hour. An infiltration rate of 15 mm/hour means that a water layer of 15 mm on the soil surface, will take one hour to infiltrate.

Consider checking attachment for the step by step solution.

6 0
3 years ago
2. A mild steel wire of radius 0.5mm and length 3m is stretched by a force of 49 N. Calculate:
damaskus [11]
I don’t know how to answer :’(
6 0
2 years ago
Q4. (20 points) For a bronze alloy, the stress at which plastic deformation begins is 271 MPa and the modulus of elasticity is 1
babunello [35]

Answer:

a) P = 86720 N

b) L = 131.2983 mm

Explanation:

σ = 271 MPa = 271*10⁶ Pa

E = 119 GPa = 119*10⁹ Pa

A = 320 mm² = (320 mm²)(1 m² / 10⁶ mm²) = 3.2*10⁻⁴ m²

a) P = ?

We can apply the equation

σ = P / A     ⇒    P = σ*A = (271*10⁶ Pa)(3.2*10⁻⁴ m²) = 86720 N

b) L₀ = 131 mm = 0.131 m

We can get ΔL applying the following formula (Hooke's Law):

ΔL = (P*L₀) / (A*E)    ⇒  ΔL = (86720 N*0.131 m) / (3.2*10⁻⁴ m²*119*10⁹ Pa)

⇒  ΔL = 2.9832*10⁻⁴ m = 0.2983 mm

Finally we obtain

L = L₀ + ΔL = 131 mm + 0.2983 mm = 131.2983 mm

3 0
3 years ago
Urgent please help!<br> What are non-ferrous metal and ferrous metal?
m_a_m_a [10]
In metallurgy, non-ferrous metals are metals or alloys that do not contain iron in appreciable amounts. Generally more costly than ferrous metals, non-ferrous metals are used because of desirable properties such as low weight, higher conductivity, non-magnetic property or resistance to corrosion
8 0
2 years ago
Any change in the system from one equilibrium state to another is called: A) Path B) Process C) Cycle D) None of the above
dexar [7]

Answer:

B) Process

Explanation:

In thermodynamics a process is a passage of a thermodynamic system from an initial to a final state of thermodynamic equilibrium.

A thermodynamic process path is the series of states through which a system passes from an initial to a final state.

Cycle is a process in which initial and final state are identical.

7 0
3 years ago
Other questions:
  • The internal loadings at a critical section along the steel drive shaft of a ship are calculated to be a torque of 2300 lb⋅ft, a
    8·1 answer
  • A ball thrown vertically upward from the top of a building of 60ft with an initial velocity of vA=35 ft/s. Determine (a) how hig
    8·1 answer
  • 1. The area of the given triangle is 25 square units. What is the value of x?<br> X+2
    8·1 answer
  • Design a digital integrator using the impulse invariance method. Find and give a rough sketch of the amplitude response, and com
    15·1 answer
  • A Pelton wheel is supplied with water from a lake at an elevation H above the turbine. The penstock that supplies the water to t
    6·1 answer
  • Who else hates this because i do
    12·2 answers
  • The Aluminum Electrical Conductor Handbook lists a dc resistance of 0.01558 ohm per 1000 ft at 208C and a 60-Hz resistance of 0.
    11·1 answer
  • Consider the formation of p-nitrophenol from p-nitrophenyl trimethyl acetate. The process is known as enzymatic hydrolysis and i
    7·1 answer
  • Quản trị học là gì ? ý nghĩa của quản trị học với thực tế xã hội
    10·1 answer
  • Close to 16 billion pounds of ethylene glycol (EG) were produced in 2013. It previously ranked as the twenty-sixth most produced
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!