I'm trying to make a program about polar problem as following but it
doesn't give right answer I think problem in formula this is right if
yes then what should be changes are made.plz send urgent reply
#include<iostream.h>
#include<conio.h>
#include<math.h>
class Polar;
class Rectangle
{
int x;
int y;
public:
Rectangle() { x=0;y=0;}
Rectangle(int x,int y)
{
this->x=x;
this->y=y;
}
Rectangle(Polar P);
int getX() { return x; }
int getY() { return y; }
Rectangle operator+(Rectangle R2)
{
Rectangle R3;
R3.x=x+R2.x;
R3.y=y+R2.y;
return R3;
}
};
class Polar
{
int r;
int a;
public:
Polar()
{
r=0;
a=0;
}
Polar(int r,int a)
{
this->r=r;
this->a=a;
}
Polar(Rectangle &R)
{
a=atan(R.getX()/R.getY());//a=atan(x/y);
r=sqrt(R.getX()*R.getX()+R.getY()*R.getY());//r=sqrt
(x*x+y*y);
}
int getR()
{
return r;
}
int getA()
{
return a;
}
Polar operator+(Polar P2)
{
Rectangle R1(*this);
Rectangle R2(P2);
Rectangle R3;
R3=R1+R2;
Polar P3(R3);
return P3;
}
void dis()
{
cout<<"\n"<<r<<"\n"<<a;;
}
};
Rectangle::Rectangle(Polar P)
{
x=P.getR()*cos(P.getA());//x=r*cos(a);
y=P.getR()*sin(P.getA());//y=r*sin(a);
}
int main()
{
clrscr();
Polar P1(5,90),P2(5,90);
Polar P3;
P3=P1+P2;
P1.dis();
P2.dis();
P3.dis();
return 0;
}