Computers and Technology

Add the following method to the point class:

public double distance(point other)

returns the distance between the current point object and the given other point object. the distance between two points is equal to the square root of the sum of the squares of the differences of their x- and y-coordinates. in other words, the distance between two points (x1, y1) and (x2, y2) can be expressed as the square root of (x2 - x1)2 + (y2 - y1)2. two points with the same (x, y) coordinates should return a distance of 0.0.

public class point {
int x;
int y;

// your code goes here

}
2.

create a class called name that represents a person's name. the class should have fields named firstname representing the person'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.

3.

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.".

4.

add the following method to the point class:

public int quadrant()

returns which quadrant of the x/y plane this point object falls in. quadrant 1 contains all points whose x and y values are both positive. quadrant 2 contains all points with negative x but positive y. quadrant 3 contains all points with negative x and y values. quadrant 4 contains all points with positive x but negative y. if the point lies directly on the x and/or y axis, return 0.

public class point {
private int x;
private int y;

// your code goes here

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:10, ryan23allen
For each of the following claims, determine whether they are true or false. justify your determination (show your work). if the claim is false, state the correct asymptotic relationship as o, θ, or ω. unless otherwise specified, lg is log2.(a) (b) (c) (d) (e) (f) (g) (h) (i) (j)n+1 =22n =2n =1 =ln2 n =n2 +2n−4 =33n = 2n+1 =√n = 10100 =o(n4) o(2n)θ(2n+7 ) o(1/n)θ(lg2 n) ω(n2 )θ(9n ) θ(2n lg n )o(lg n) θ(1)
Answers: 1
image
Computers and Technology, 22.06.2019 07:30, haleyblu6351
By refraining from constructing a building until they are certain that it will not cause harm to the environment, an organization is adhering to the
Answers: 2
image
Computers and Technology, 22.06.2019 11:00, ed72018373
Which law requires employers to provide safe working environments for their employees? a. civil rights act b. fair labor standards act c. occupational safety and health act d. wagner act
Answers: 1
image
Computers and Technology, 22.06.2019 14:30, binodkharal2048
Hi plz 11 ! when planning a table, what step comes first: "define the column headers" or "calculate the number of columns/rows"? a. calculate the number of columns/rows b. define the column headers
Answers: 1
Do you know the correct answer?
Add the following method to the point class:

public double distance(point other)
<...

Questions in other subjects:

Konu
Arts, 09.12.2020 01:00
Konu
History, 09.12.2020 01:00