• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Sep 18th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2.
3. using namespace std;
4.
5. int main();
6.
7. int centimeter_convert(int imp) {
8.     // Converts to centimeters
9.     int cont;
10.     float inches = 0.39;
11.     float cm = 2.54;
12.     float num;
13.     if (imp == 1) {
14.         cout << "Enter a number to convert." << endl;
15.         cout << "Inches: ";
16.         cin >> inches;
17.         num = cm * inches;
18.         cout << inches << " Inches is " << num << " Cenimeters" << endl;
19.         cout << "(1)Convert again || (2)Go back || (3)Exit ";
20.         cin >> cont;
21.         } else if (imp == 2) {
22.             cout << "Enter a number to convert." << endl;
23.             cout << "Centimeters: ";
24.             cin >> cm;
25.             num = inches * cm;
26.             cout << cm << " Centimeters is " << num << " Inches" << endl;
27.             cout << "(1)Convert again || (2)Go back || (3)Exit ";
28.             cin >> cont;
29.     }
30.
31.     if (cont == 1) {
32.         centimeter_convert(imp);
33.     } else if (cont == 2) {
34.         main();
35.     } else {
36.         cout << "Shutting down...";
37.     }
38.     return 0;
39. }
40.
41. int metres_convert(int imp) {
42.     // Converts to metres
43.     int cont;
44.     float feet = 3.2;
45.     float metres = 0.30;
46.     float num;
47.     if (imp == 1) {
48.         cout << "Enter a number to convert." << endl;
49.         cout << "Feet: ";
50.         cin >> feet;
51.         num = metres * feet;
52.         cout << feet << " Feet is " << num << " Metres" << endl;
53.         cout << "(1)Convert again || (2)Go back || (3)Exit ";
54.         cin >> cont;
55.     } else if (imp == 2) {
56.         cout << "Enter a number to convert." << endl;
57.             cout << "Metres: ";
58.             cin >> metres;
59.             num = feet * metres;
60.             cout << metres << " Metres is " << num << " Feet" << endl;
61.             cout << "(1)Convert again || (2)Go back || (3)Exit ";
62.             cin >> cont;
63.     }
64.      if (cont == 1) {
65.         metres_convert(imp);
66.      } else if (cont == 2) {
67.         main();
68.      } else {
69.         cout << "Shutting down...";
70.      }
71.      return 0;
72. }
73.
74. int kilometres_convert(int imp) {
75.     // Coverts to metres
76.     int cont;
77.     float kilometres = 1.60;
78.     float miles = 0.62;
79.     float num;
80.     if (imp == 1) {
81.         cout << "Enter a number to convert." << endl;
82.         cout << "Miles: ";
83.         cin >> miles;
84.         num = kilometres * miles;
85.         cout << miles << " Miles is " << num << " Kilometres" << endl;
86.         cout << "(1)Convert again || (2)Go back || (3)Exit ";
87.         cin >> cont;
88.     } else if (imp == 2) {
89.         cout << "Enter a number to convert." << endl;
90.         cout << "Kilometres: ";
91.         cin >> miles;
92.         num = miles * kilometres;
93.         cout << kilometres << " Kilometres is " << num << " Miles" << endl;
94.         cout << "(1)Convert again || (2)Go back || (3)Exit ";
95.         cin >> cont;
96.     }
97.     if (cont == 1) {
98.         kilometres_convert(imp);
99.     } else if (cont == 2) {
100.         main();
101.     } else {
102.         cout << "Shutting down...";
103.     }
104.     return 0;
105. }
106.
107. void imperial_to_metric() {
108.     // Converts Imperial to Metric
109.     int option;
110.     cout << "Choose a measurement unit" << endl;
111.     cout << "1.Inches 2.Feet 3.Miles : ";
112.     cin >> option;
113.
114.     if (option == 1) {
115.         centimeter_convert(1);
116.     } else if (option == 2) {
117.         metres_convert(1);
118.     } else if (option == 3) {
119.         kilometres_convert(1);
120.     }
121. }
122.
123. void metric_to_imperial() {
124.     // Converts Metric to Imperial
125.     int option;
126.     cout << "Choose a measurement unit" << endl;
127.     cout << "1.Centimetres 2.Metres 3.Kilometres";
128.     cin >> option;
129.
130.     if (option == 1) {
131.         centimeter_convert(2);
132.     } else if (option == 2) {
133.         metres_convert(2);
134.     } else if (option == 3) {
135.         kilometres_convert(2);
136.     }
137. }
138.
139.
140. int main() {
141.     // Imperial to metric system converter
142.     int quest;
143.     cout << "(1)Imperial to Metric OR (2)Metric to Imperial ";
144.     cin >> quest;
145.
146.     if (quest == 1) {
147.         // Return Imperial to Metric
148.         imperial_to_metric();
149.     } else if (quest == 2) {
150.         // Return Metric to Imperial
151.         metric_to_imperial();
152.     } else if (quest != 1 || 2) {
153.         cout << "Enter 1 or 2 to choose a conversion method." << endl;
154.         main();
155.     }
156.
157. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top