Add 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 (x₁, y₁) and (x₂, y₂) can be expressed as the square root of (x₂ (₂-₁)². Two points with the same (x, y) coordinates should return a distance of 0.0. x₁ )² + Il. (You must complete Self-Check Problem 7 before answering this question.) 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 exam- ple, if the first name is "John", the middle initial is "Q", and the last name is "Public", 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", returns "Public, John Q.". uboca obiects can easily be printed on the console?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question
Number 11
Add a new method to the Point class we developed in this chapter:
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 (x₁, y₁) and (x₂, y₂) can be expressed as the square root of (x₂
(₂-₁)². Two points with the same (x, y) coordinates should return a distance of 0.0.
x₁ )² +
11. (You must complete Self-Check Problem 7 before answering this question.)
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 exam-
ple, if the first name is "John", the middle initial is "Q", and the last name is "Public", 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", returns "Public, John Q.".
12. How do you write a class whose objects can easily be printed on the console?
13. The following println statement (the entire line) is equivalent to what?
Point pl = new Point();
...
System.out.println (pl);
a. System.out.println(toString(pl));
b. pl.toString();
c. System.out.println (pl.toString());
d. System.out.println(pl.string());
e. System.out.println (Point.toString());
Transcribed Image Text:Add a new method to the Point class we developed in this chapter: 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 (x₁, y₁) and (x₂, y₂) can be expressed as the square root of (x₂ (₂-₁)². Two points with the same (x, y) coordinates should return a distance of 0.0. x₁ )² + 11. (You must complete Self-Check Problem 7 before answering this question.) 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 exam- ple, if the first name is "John", the middle initial is "Q", and the last name is "Public", 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", returns "Public, John Q.". 12. How do you write a class whose objects can easily be printed on the console? 13. The following println statement (the entire line) is equivalent to what? Point pl = new Point(); ... System.out.println (pl); a. System.out.println(toString(pl)); b. pl.toString(); c. System.out.println (pl.toString()); d. System.out.println(pl.string()); e. System.out.println (Point.toString());
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education