Question: Two doubles are read as the x and the y of a Coordinates object. Assign pointer myCoordinates with a new Coordinates object using the x

Two doubles are read as the x and the y of a Coordinates object. Assign pointer myCoordinates with a new Coordinates object using the x and the y as arguments in that order.
Ex: If the input is 7.58.0, then the output is:
Coordinates's x: 7.5
Coordinates's y: 8.0
#include
#include
using namespace std;
class Coordinates {
public:
Coordinates(double xValue, double yValue);
void Print();
private:
double x;
double y;
};
Coordinates::Coordinates(double xValue, double yValue){
x = xValue;
y = yValue;
}
void Coordinates::Print(){
cout << "Coordinates's x: "<< fixed << setprecision(1)<< x << endl;
cout << "Coordinates's y: "<< fixed << setprecision(1)<< y << endl;
}
int main(){
Coordinates* myCoordinates = nullptr;
double xValue;
double yValue;
cin >> xValue;
cin >> yValue;
myCoordinates->Print();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!