-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlab3_q5.cpp
More file actions
53 lines (49 loc) · 1.04 KB
/
lab3_q5.cpp
File metadata and controls
53 lines (49 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
5. Polar coordinates are represented in angle and radius format while rectangular
coordinates represented as (x,y). Define classes for both types and include member
functions to convert from polar to rectangular coordinates.(conversion from class to class.)
*/
#include <iostream>
#include <cmath>
using namespace std;
class polar{
double radius,angle,radian;
public:
polar(double r,double a){
radius=r;
angle=a;
}
double getRadius(){
return (radius);
}
double getAngle(){
radian=(angle*3.14159)/180;
return(radian);
}
};
class rect{
double x,y;
public:
rect (){};
rect(polar p){
x=p.getRadius()*cos(p.getAngle());
y=p.getRadius()*sin(p.getAngle());
}
void display(){
cout<<"Rectangular Form is \n";
cout<<"X= "<<x<<"\n"<<"Y = "<<y<<endl;
}
};
int main(){
cout<<"-----POLAR TO RECTANGULAR CONVERSION-----\n";
double r,a;
rect R;
cout<<"\nEnter the radius = ";
cin>>r;
cout<<"\nEnter the angle(in degree)= ";
cin>>a;
polar P(r,a);
R=P;
R.display();
return 0;
}