Computers and Technology
Computers and Technology, 19.03.2021 17:10, Anabel818

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
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 20:20, ab847150
Wireless communications is likely to be viewed as an essential part of an enterprise network infrastructure when: select one: a. mobile communication is needed b. communication facilities must be installed at low initial cost c. communication must take place in a hostile or difficult terrain that makes wired communication difficult or impossible d. the same information must be broadcast to many locations
Answers: 1
image
Computers and Technology, 22.06.2019 17:30, yoyo9661
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
image
Computers and Technology, 22.06.2019 18:00, alexj29227405
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
image
Computers and Technology, 23.06.2019 01:00, lusciousl
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan. in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan. out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
Do you know the correct answer?
1. Add the following method to the Point class: public double distance(Point other)
Returns t...

Questions in other subjects:

Konu
Mathematics, 22.08.2019 00:30
Konu
Mathematics, 22.08.2019 00:30
Konu
Mathematics, 22.08.2019 00:30