public class polar
{
//polar coordinate system

protected double R,teta;

public polar()
{
R=0;
teta=0;
}

public polar(double Ri,double tetai)
{
R=Ri;
teta=tetai;
}

public polar(polar y)
{
R=y.R();
teta=y.teta();
}

public void inputR(double Ri)
{
R=Ri;
}

public void inputTeta(double tetai)
{
teta=tetai;
}


public void inputPolar(double Ri,double tetai)
{
R=Ri;
teta=tetai;
}

public void inputCartesian(double xi,double xj)
{
R=Math.sqrt(xi*xi+xj*xj);
teta=Math.atan2(xj,xi);
}

public double R()
{
return R;
}

public double teta()
{
return teta;
}

public double xi()
{
return R*Math.cos(teta);
}

public double xj()
{
return R*Math.sin(teta);
}

public void add(polar y)
{
 inputCartesian((xi()+y.xi()),(xj()+y.xj()));
}


public void substract(polar y)
{
  inputCartesian((xi()-y.xi()),(xj()-y.xj()));
}

public polar read_polar()
{
return this;
}

public boolean equals(polar v)
{
boolean b=((R==v.R())&&(teta==v.teta()));
return b;
}

public boolean greater_than(polar v)
{
  return (R>v.R());
}

public boolean smaller_than(polar v)
{
  return (R<v.R());
}

public String toString()
{
 return ""+R+"*exp("+teta+"i) ";
}
}
