// CS2 Chung // Application: How many rotations? #include class Point { private: double x; double y; public: Point() { x = 0; y = 0; } Point(double init_x, double init_y) { x = init_x; y = init_y; } double get_x() const { return x; } double get_y() const { return y; } void rotate90() { double temp; temp = x; x = y; y = -temp; } friend istream& operator >> (istream& ins, Point& target) { cout << "Enter x and y for a point: "; ins >> target.x >> target.y; return ins; } friend /* ostream& */ void operator << (ostream& outs, Point& source) { outs << "(" << source.x << ", "; outs << source.y << ")" << endl; // return outs; } }; int rotations_needed(Point p) { int ans = 0; while((p.get_x() < 0) || (p.get_y() < 0)) { p.rotate90(); ans++; } return ans; } void main() { Point p1; cin >> p1; cout << p1; cout << "Rotations needed to move to upper right quadrant: " << rotations_needed(p1); }