-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcast.cpp
58 lines (57 loc) · 998 Bytes
/
cast.cpp
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
54
55
56
57
58
#include<iostream>
#define PI 3.1416
using namespace std;
class radian
{
float rad;
public:
radian(float ini=0){rad=ini;}
void input()
{
cout<<"ENTER THE VALUE IN RADIAN\n";
cin>>rad;
}
float getradian()
{
return(rad);
}
void output()
{
cout<<"Radian = "<<getradian();
}
};
class degree
{ float deg;
public:
degree(float x=0){deg=x;}
degree(radian x)
{
deg=(x.getradian()*180)/PI ; //M_PI is the value of pi
}
operator radian()
{
return (radian((deg*PI)/180));
}
void input()
{cout<<"ENTER VALUE IN DEGREE\n";
cin>>deg;
}
void output()
{
cout<<"DEGREE = "<<deg;
}
};
int main()
{
degree deg;
radian rad;
cout<<"CONVERT DEGREE INTO RADIAN\n";
deg.input();
rad=deg;
rad.output();
cout<<"\nCONVERT RADIAN INTO DEGREE\n";
rad.input() ;
deg=rad ;
deg.output() ;
return 0;
}