Question: #include #include using namespace std; // Vector class definition class Vector { // Private data members float X, public: // Default constructor, with 0 arguments
#include#include using namespace std; // Vector class definition class Vector { // Private data members float X, public: // Default constructor, with 0 arguments // This constructor assigns default values // to X and Y Vector() { X = 0 Y = 0 // Constructor with 1 argument, that assigns // the argument to X and the default value to Y Vector (float x) { X = x Y = 0 } // Constructor with 2 arguments, that assigns // the arguments to X and Y Vector (float x, float y) { X = x; Y = y; } // Setter method for X void setX(float x) { X = x; } // Getter method for X float getX() { cout << "X = " endl; return X; } // Setter method for Y void setY(float y) { Y = y; } // Getter method for Y float getY() { cout << "Y = " << Y << endl; return Y; } // magnitude class method that returns the // magnitude of the vector float magnitude() { return sqrt(); } // direction class method that returs the // direction of the vector float direction() { return atan(Y / X); } }; int main() { // Instantiating Vector objects Vector v1; Vector v2 Vector v3; // Setting the X and Y values of v1 v1.setX(2); v1.setY(3); // Displaying the properties of the Vector objects cout << "The properties of Vector 1 are: " << endl; v1.getX v1.getY(); cout << "Magnitude: " << v1.magnitude() << endl; cout << "Direction: " << v1.direction() << endl; cout << "The properties of Vector 2 are: " << endl; v2.getX(); v2.getY(); cout << Magnitude: << v2.magnitude() << endl; cout << "Direction: " << v2.direction() << endl; cout << "The properties of Vector 3 are: " << endl; v3.getX(-); v3.getY(-); cout << "Magnitude: " << v3.magnitude() << endl; cout << "Direction: " << v3.direction() << endl; #include #include using namespace std; // Vector class definition class Vector { // Private data members float X, public: // Default constructor, with 0 arguments // This constructor assigns default values // to X and Y Vector() { X = 0 Y = 0 // Constructor with 1 argument, that assigns // the argument to X and the default value to Y Vector (float x) { X = x Y = 0 } // Constructor with 2 arguments, that assigns // the arguments to X and Y Vector (float x, float y) { X = x; Y = y; } // Setter method for X void setX(float x) { X = x; } // Getter method for X float getX() { cout << "X = " endl; return X; } // Setter method for Y void setY(float y) { Y = y; } // Getter method for Y float getY() { cout << "Y = " << Y << endl; return Y; } // magnitude class method that returns the // magnitude of the vector float magnitude() { return sqrt(); } // direction class method that returs the // direction of the vector float direction() { return atan(Y / X); } }; int main() { // Instantiating Vector objects Vector v1; Vector v2 Vector v3; // Setting the X and Y values of v1 v1.setX(2); v1.setY(3); // Displaying the properties of the Vector objects cout << "The properties of Vector 1 are: " << endl; v1.getX v1.getY(); cout << "Magnitude: " << v1.magnitude() << endl; cout << "Direction: " << v1.direction() << endl; cout << "The properties of Vector 2 are: " << endl; v2.getX(); v2.getY(); cout << Magnitude: << v2.magnitude() << endl; cout << "Direction: " << v2.direction() << endl; cout << "The properties of Vector 3 are: " << endl; v3.getX(-); v3.getY(-); cout << "Magnitude: " << v3.magnitude() << endl; cout << "Direction: " << v3.direction() << endl; return 0; }
Please fix my code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
