By implementing the concepts of Classes and Objects, write a C++ program that determines the distance between 2 points in a coordinate system. The coordinates of the 2 points: P1 (x1, y1) and P2(x2, y2) are to be entered from the keyboard. The distance, d, between the 2 points is computed as : d= V(2 – y1)² + (x2 – x1)² Accomplish the following for the given class diagram: Point 1.) Create the class implementation using C++ x: int 2.) Using the constructor, create 2 objects, P1 and P2, from y: int class Point and store them in the heap memory. + Point( x : int, y : int ) + setXY(): void + getX( ) : int + getY( ) : int 3.) Implement the functions of the 2 objects. NOTE: The member function setXY is used to enter the values of x and y from the keyboard. Sample input/output display: Enter the coordinates of the 1* point (x1 y1): 1 1 Enter the coordinates of the 2nd point (x2 y2): 5 4 The distance, d, between P(1,1) and P(5,4) = 5

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Using C++, show the code for this problem

By implementing the concepts of Classes and Objects, write a C++ program that determines
the distance between 2 points in a coordinate system. The coordinates of the 2
points: P1 (x1, y1) and P2(x2, y2) are to be entered from the keyboard. The distance, d,
between the 2 points is computed as : d= /(y2 – y1)² + (x2 – x1)2
Accomplish the following for the given class diagram:
Point
1.) Create the class implementation using C++
x: int
2.) Using the constructor, create 2 objects, P1 and P2, from
y : int
+ Point( x : int, y : int )
class Point and store them in the heap memory.
+ setXY( ): void
3.) Implement the functions of the 2 objects.
+ getX() : int
+ getY( ) : int
NOTE: The member function setXY is used to enter the values of x and y from the
keyboard.
Sample input/output display:
Enter the coordinates of the 1st point (x1 y1): 1 1
Enter the coordinates of the 2nd point (x2 y2): 5 4
The distance, d, between P(1,1) and P(5,4) = 5
Transcribed Image Text:By implementing the concepts of Classes and Objects, write a C++ program that determines the distance between 2 points in a coordinate system. The coordinates of the 2 points: P1 (x1, y1) and P2(x2, y2) are to be entered from the keyboard. The distance, d, between the 2 points is computed as : d= /(y2 – y1)² + (x2 – x1)2 Accomplish the following for the given class diagram: Point 1.) Create the class implementation using C++ x: int 2.) Using the constructor, create 2 objects, P1 and P2, from y : int + Point( x : int, y : int ) class Point and store them in the heap memory. + setXY( ): void 3.) Implement the functions of the 2 objects. + getX() : int + getY( ) : int NOTE: The member function setXY is used to enter the values of x and y from the keyboard. Sample input/output display: Enter the coordinates of the 1st point (x1 y1): 1 1 Enter the coordinates of the 2nd point (x2 y2): 5 4 The distance, d, between P(1,1) and P(5,4) = 5
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning