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
In the High Low Logic Index low levels are bearish and high levels are bullish, generally True False
Irina-Kira [14]

Answer:

True

Explanation:

Logic index is selection of values based on the logical streams. The values appear on the logical array. The levels are determined on the market investment performance. If there are many buyers available in the market the index will be high and the market will be bullish. If there are few or no investors available the market index will be low which means the market is bearish.

8 0
2 years ago
Assume the availability of an existing class, ICalculator, that models an integer arithmetic calculator and contains: an instanc
shtirl [24]

We connect with computers through coding, often known as computer programming.

<h3>How to code?</h3>
  • We connect with computers through coding, often understood as computer programming.
  • Coding exists similar to writing a set of instructions because it instructs a machine what to do.
  • You can instruct computers what to do or how to behave much more quickly by learning to write code.

class ICalculator {

int currentValue;

int add(int value) {

this.currentValue = currentValue + value;

return currentValue;

}

int sub(int value) {

this.currentValue = currentValue - value;

return currentValue;

}

int mul(int value) {

this.currentValue = currentValue * value;

return currentValue;

}

int div(int value) {

this.currentValue = currentValue / value;

return currentValue;

}

}

public class ICalculator2 extends ICalculator {

int negate() {

if (currentValue != 0)

this.currentValue = -currentValue;

return currentValue;

}

public static void main(String[] args) {

ICalculator2 ic = new ICalculator2();

ic.currentValue=5;

System.out.println(ic.add(2));

System.out.println(ic.sub(5));

System.out.println(ic.mul(3));

System.out.println(ic.div(3));

System.out.println(ic.negate());

}

}

To learn more about code, refer to

brainly.com/question/22654163

#SPJ4

3 0
1 year ago
Where can you find free air pods that look real
Tema [17]
You can find air pods that look real on letgo. or you can go to wish.com but if you want a good pair jus get the real ones
7 0
3 years ago
2. What is the Function of the Camshaft in an Internal Combustion Engine?
mamaluj [8]

Answer:

camshaft, in internal-combustion engines, rotating shaft with attached disks of irregular shape (the cams), which actuate the intake and exhaust valves of the cylinders.

Explanation:

I'm taking an engineering/tech class. I hope this helps! :)

8 0
2 years ago
The electric motor exerts a torque of 800 N·m on the steel shaft ABCD when it is rotating at a constant speed. Design specificat
kodGreya [7K]

Answer:

d= 4.079m ≈ 4.1m

Explanation:

calculate the shaft diameter from the torque,    \frac{τ}{r} = \frac{T}{J} = \frac{C . ∅}{l}

Where, τ = Torsional stress induced at the outer surface of the shaft (Maximum Shear stress).

r = Radius of the shaft.

T = Twisting Moment or Torque.

J = Polar moment of inertia.

C = Modulus of rigidity for the shaft material.

l = Length of the shaft.

θ = Angle of twist in radians on a length.  

Maximum Torque, ζ= τ ×  \frac{ π}{16} × d³

τ= 60 MPa

ζ= 800 N·m

800 = 60 ×  \frac{ π}{16} × d³

800= 11.78 ×  d³

d³= 800 ÷ 11.78

d³= 67.9

d= \sqrt[3]{} 67.9

d= 4.079m ≈ 4.1m

3 0
2 years ago
Read 2 more answers
Other questions:
  • Assuming that the following three variables have already been declared, which variable will store a Boolean value after these st
    14·1 answer
  • A hot-water stream at 80°C enters a mixing chamber with a mass flow rate of 0.46 kg/s where it is mixed with a stream of cold wa
    14·1 answer
  • What type of fuel does a 2 cycle engine use
    5·1 answer
  • URGENT PLEASE HELP!!!
    11·1 answer
  • A person is interested in becoming an electrician. What are some appropriate types of preparation that this individual can consi
    7·2 answers
  • Which battery produces more volts per cell, maintenance type or maintenance free ?
    6·1 answer
  • PLEASE FIX THIS LUA SCRIPT
    12·2 answers
  • What is valve overlap?
    5·1 answer
  • Reason fo I.EE regulations in electrical installations​
    13·1 answer
  • 1. What did observations between 1912 and 1917 show?_____
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!