/*********************************************
This program creates a text-file for Excel
that plots a course steered by the user.
Our position starts at (0,0), and the user
enters moves in (dx,dy) format, with a "q"
to quit.
**********************************************/
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
 
/*********************************************
 ** PROTOTYPES & STRUCT DEFINITIONS
 *********************************************/
struct Point
{
  double x,y;
};
bool getMove(Point &p, istream &IN);
 
/*********************************************
 ** MAIN FUNCTION
 *********************************************/
int main()
{
  // Initialization
  ofstream OUT("out.txt");
  Point p,m;
  p.x = p.y = m.x = m.y = 0;
 
  // Get moves & write moves
  do {
    // Compute new position p from move m
    p.x = p.x + m.x;
    p.y = p.y + m.y;
 
    // Write move
    OUT << p.x << '\t' << p.y << endl;
    
  }while(getMove(m,cin));
 
  return 0;
}
 
/*********************************************
 ** FUNCTION DEFINITIONS
 *********************************************/
// Gets tht next more from the user & stores
// in point p.  Returns true if read was
// successful, and false otherwise
bool getMove(Point &p, istream &IN)
{
  cout << "Enter move vector: ";    
  char c;
  if (IN >> c && c == '(' && IN >> p.x &&
      IN >> c && c == ',' && IN >> p.y &&
      IN >> c && c == ')')
    return true;
  else
    return false;
}