subject

1. 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
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:30
You have a small company and want to keep your costs low, but it is important your employees share data. which network would provide you with the most economical solution?
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
The basic work area of the computer is it screen that you when you first fire up your computer
Answers: 1
question
Computers and Technology, 23.06.2019 23:00
Computer programming is one type of what career
Answers: 1
question
Computers and Technology, 24.06.2019 08:50
Write a program that will compute the volume of ice cream served in a cone. as you can see in the diagram below, the ice cream is served as a hemisphere of frozen deliciousness on top of a cone, which is also packed with frozen deliciousness. thus, the total volume of ice cream sold is the volume of the hemisphere plus the volume of the cone. the example shows an ice cream cone in which the hemisphere and cone have a radius of 10 inches and the cone has a height of 15 inches. your program must instead prompt for these two values, which are taken from the keyboard as integers: • the hemisphere/cone radius in inches, and
Answers: 3
You know the right answer?
1. Add the following method to the Point class: public double distance(Point other)
Returns t...
Questions
question
Mathematics, 11.12.2020 01:00
question
Social Studies, 11.12.2020 01:00
question
Mathematics, 11.12.2020 01:00
question
Mathematics, 11.12.2020 01:00
question
Mathematics, 11.12.2020 01:00
Questions on the website: 13722361