Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use simple C++ Point programming. I have wrote my C++ Point program, but I’m not

ID: 3756495 • Letter: U

Question

Use simple C++ Point programming. I have wrote my C++ Point program, but I’m not quite sure if it’s correct or not. Thank you. Use simple C++ Point programming. I have wrote my C++ Point program, but I’m not quite sure if it’s correct or not. Thank you. Use simple C++ Point programming. I have wrote my C++ Point program, but I’m not quite sure if it’s correct or not. Thank you. Point.h file is down below
Point.cpp is below
My C++ program is below
#include "Point.cpp" // required for Point #include <iostream> // required for cin and cout using namespace std;

int main() { Point p1, p2; // Declare two Point objects double x, y, dist; char pause;    // Set value of the Point objects
cout << "/n Enter x coordinate for point p1: "; cin >> x; cout << "/n Enter y coordinate for point p1: "; cin >> y;
p1.setX(x); p1.setY(y);
cout << "/n Enter x coordinate for point p2: "; cin >> x; cout << "/n Enter y coordinate for point p2: "; cin >> y;
// Set the value of p1 and p2 p2.setX(x); p2.setY(y);
// Print the value of p1 and p2 cout << "p1: (" << p1.getX() << "," << p1.getY() << ")" << endl; cout << "p2: (" << p2.getX() << "," << p2.getY() << ")" << endl;
// Calculate the distance between p1 and p2 dist = p1 - p2; cout << "Distance between p1 and p2 is " << dist << endl; cin >> pause; return 0; } #include "Point.cpp" // required for Point #include <iostream> // required for cin and cout using namespace std;

int main() { Point p1, p2; // Declare two Point objects double x, y, dist; char pause;    // Set value of the Point objects
cout << "/n Enter x coordinate for point p1: "; cin >> x; cout << "/n Enter y coordinate for point p1: "; cin >> y;
p1.setX(x); p1.setY(y);
cout << "/n Enter x coordinate for point p2: "; cin >> x; cout << "/n Enter y coordinate for point p2: "; cin >> y;
// Set the value of p1 and p2 p2.setX(x); p2.setY(y);
// Print the value of p1 and p2 cout << "p1: (" << p1.getX() << "," << p1.getY() << ")" << endl; cout << "p2: (" << p2.getX() << "," << p2.getY() << ")" << endl;
// Calculate the distance between p1 and p2 dist = p1 - p2; cout << "Distance between p1 and p2 is " << dist << endl; cin >> pause; return 0; } You will create and use Point, a programmer-defined data type which describes points in the Cartesian coordinate system. Each "Point" has an x-coordinate and a y-coordinate. The Point data type does not exist in Ctt, so you must create separate files defining Point to the compiler and explaining how it will work. Since C++ is case-sensitive, you must be consistent with case when creating and referencing a class. Capitalize the first letter so that the new class will be called Point, not point or POINT. Name the associated files Point.h and Point.cpp using the capitalized format so the compiler will understand that they all refer to the same class. In Dev C+t, you will create a project (not just a source code file) and add three files to your project. When you compile the program, all three files inside the project will compile together. This will work best if all the files are placed in the same directory together. When you submit your program, upload the project (.dev file) and your source code (cpp file) through the link provided. When your Instructor opens the .dev file, C++ will expect to find the three files that belong inside of the .dev file. Since everyone is using the same Point.h and Point.cpp files, you do not need to submit those files through Blackboard (as long as you do not change them) but you do need to put them in your project when you compile it. Then your Instructor can use a copy of the Point.h and Point.cpp from the textbook with your source code file, and your C++ project will behave as it did when you compiled it.

Explanation / Answer

Point.h file :

#ifndef POINT_H

#define POINT_H

#include<iostream>

using namespace std;

class Point

{

private:

double xCoord;

double yCoord;

public:

Point();

Point(double,double);

double getX()const;

double getY()const;

friend ostream& operator<<(std::ostream&, const Point&);

void setX(double);

void setY(double);

double operator -(const Point&)const;

};

#endif

IN Point.cpp remove print method and Add this method:

ostream &operator<<(std::ostream&out, const Point&P)

{

out<<"("<<P.getX()<<","<<P.getY()<<")";

}

then you can call directly cout<<P

and remainig parts are okay

PLEASE GIVE THUMBS UP,THANKS