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

The cost must be c++ Read the provided code for the Point class that represents

ID: 647703 • Letter: T

Question

The cost must be c++

Read the provided code for the Point class that represents a point on a standard Cartesian plane. Then read the provided code in main.
Replace YOUR_CODE with code that will read an x and y value from stdin (console) and create a Point p1 at those coordinates.

#include <iostream>
using namespace std;

class Point {
private:
double x;
double y;

public:
Point() {
  x = 0;
  y = 0;
}

Point(double xLoc, double yLoc) {
  x = xLoc;
  y = yLoc;
}

double getX() {
  return x;
}

double getY() {
  return y;
}
};

int main()
{

//Do not modify anything on or above the line below this
//START_PROVIDED


    //YOUR_CODE


//END_PROVIDED
//Do not modify anything on or below the line above this
cout << p1.getX() << " " << p1.getY() << endl;
}

Explanation / Answer

#include <iostream>
using namespace std;

class Point {
private:
   double x;
   double y;

public:
   Point() {
       x = 0;
       y = 0;
   }

   Point(double xLoc, double yLoc) {
       x = xLoc;
       y = yLoc;
   }

   double getX() {
       return x;
   }

   double getY() {
       return y;
   }
};

int main()
{

   //Do not modify anything on or above the line below this
   double x, y;
   cin >> x >> y;
   Point p1 = Point(x, y);
   //Do not modify anything on or below the line above this
   cout << p1.getX() << " " << p1.getY() << endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote