# OOP Lab: A Class that determine polar coordinates

#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
class polar{
float r,a;
public:
void setpolar(float i, float j){ r=i; a=j; }
void showpolar()
{
<<” Angle = “<<setprecision(4)<<a;
}
void getresult(){}
polar operator + (polar ob);
};
polar polar :: operator + (polar ob){
float angle1,angle2,ang;
polar tempob;
angle1 = (22 * a) /float(7 * 180);
angle2 = (22 * ob.a)/ float (7 * 180);
x1 = r*cos(angle1);
y1 = r*sin(angle1);
x2 = ob.r * cos(angle2);
y2 = ob.r * sin(angle2);
x = x1 + x2;
y = y1 + y2;
ang = atan(y/float(x));
angle = (180*7*ang)/22;
return tempob;
}
int main()
{
float r,a;
int i;
polar ob[2],sumob;
cout<<“Determine polar coordinates\n”;
cout<<“=================\n\n\n\n\n”;
for(i=0;i<2;i++){
cout<<“\nEnter r:”<<i+1<< “:”;
cin>>r;
cout<<“\nEnter a:”<<i+1<< “:”;
cin>>a;
ob[i].setpolar(r,a);
}
cout<<“\n”;
for(i=0;i<2;i++){
cout<<“\n\n\n\n”;
cout<<i+1<<” number polar coordinate:”;
cout<<“\n\n”;
ob[i].showpolar();
cout<<“\n\n\n\n”;
}
cout<<“\n\n\n\nResult\n\n”;
sumob = ob[0] + ob[1];
sumob.showpolar();
return 0;
}