forked from Revnth/Hacktoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Physical_quantity_converter.cpp
135 lines (124 loc) · 2.61 KB
/
Physical_quantity_converter.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include<iostream>
using namespace std;
void calculator();
void kmTom();
void mToyard();
void hpTokw();
void DegToRad();
int main(){
string name;
int option;
cout<<"Hi, Welcome to universal convertor \n";
cout<<"Enter your name : ";
cin>>name;
cout<<"Hello "<<name<<"\n";
cout<<"choose your option "<<endl;
cout<< "1: calculator"<<endl;
cout<< "2: Kilometer to Meter convertor"<<endl;
cout<< "3: Meter to Yard convertor"<<endl;
cout<< "4: Horsepower to kilowatt convertor"<<endl;
cout<< "5: Degree to Radian convertor"<<endl;
cin>>option;
switch(option){
case 1:
calculator();
break;
case 2:
kmTom();
break;
case 3:
mToyard();
break;
case 4:
hpTokw();
break;
case 5:
DegToRad();
break;
default:
cout<<"Wrong option";
break;
}
}
void calculator(){
int select;
int num_1, num_2, answer;
cout<<"choose your option "<<endl;
cout<< "1: Addition "<<endl;
cout<< "2: subtraction"<<endl;
cout<< "3: Multiplication "<<endl;
cout<< "4: Division "<<endl;
cin>>select;
switch(select){
case 1:
cout<<" Addition"<<endl;
cout<<"Enter First number: " <<endl;
cin>>num_1;
cout<<"Enter second number: "<<endl;
cin>>num_2;
answer = num_1 + num_2;
cout<<"Answer : "<<answer<<endl;
break;
case 2:
cout<<" Subtraction"<<endl;
cout<<"Enter First number: " <<endl;
cin>>num_1;
cout<<"Enter second number: "<<endl;
cin>>num_2;
answer = num_1 - num_2;
cout<<"Answer : "<<answer<<endl;
break;
case 3:
cout<<" Multiplication"<<endl;
cout<<"Enter First number: " <<endl;
cin>>num_1;
cout<<"Enter second number: "<<endl;
cin>>num_2;
answer = num_1 * num_2;
cout<<"Answer : "<<answer<<endl;
break;
case 4:
cout<<" Division"<<endl;
cout<<"Enter First number: " <<endl;
cin>>num_1;
cout<<"Enter second number: "<<endl;
cin>>num_2;
answer = num_1 / num_2;
cout<<"Answer : "<<answer<<endl;
break;
default:
break;
}
}
void kmTom(){
float km;
float meter;
cout<<"\n Enter value in Kilometre: ";
cin>>km;
meter = km * 1000;
cout<<km<<" KM is equal to "<<meter << " Meter ";
}
void mToyard(){
double m;
double yard;
cout<<"\n Enter value in Meter: ";
cin>>m;
yard = m * 1.0936132983;
cout<<m<<" M is equal to "<<yard << " Yard ";
}
void hpTokw(){
float hp;
float kw;
cout<<"\n Enter value in horsepower: ";
cin>>hp;
kw = hp * 0.73549875;
cout<<hp<<" hp is equal to "<<kw << " kilowatt ";
}
void DegToRad(){
float Deg;
float Rad;
cout<<"\n Enter value in Degree: ";
cin>>Deg;
Rad = Deg * 0.0174532925;
cout<<Deg<<" Degree is equal to "<<Rad << " Radian ";
}