Skip to content

Commit 96c15a5

Browse files
authored
Merge pull request #20 from dimebot/updatedlength
Updated length
2 parents 0896b1f + 4f2480d commit 96c15a5

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

conversions.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <bits/stdc++.h>
2+
3+
namespace mlb {
4+
double inch2cm(double inches) {
5+
if (inches < 0) {
6+
throw std::invalid_argument("Input value must be non-negative");
7+
}
8+
return inches * 2.54;
9+
}
10+
double cm2inch(double centimeters) {
11+
if (centimeters < 0) {
12+
throw std::invalid_argument("Input value must be non-negative");
13+
}
14+
return centimeters * 0.393701;
15+
}
16+
double yard2cm(double yards) {
17+
if (yards < 0) {
18+
throw std::invalid_argument("Input value must be non-negative");
19+
}
20+
return yards * 91.44;
21+
}
22+
double cm2yard(double centimeters) {
23+
if (centimeters < 0) {
24+
throw std::invalid_argument("Input value must be non-negative");
25+
}
26+
return centimeters / 91.44;
27+
}
28+
double mile2km(double miles) {
29+
if (miles < 0) {
30+
throw std::invalid_argument("Input value must be non-negative");
31+
}
32+
return miles * 1.60934;
33+
}
34+
double km2mile(double kilometers) {
35+
if (kilometers < 0) {
36+
throw std::invalid_argument("Input value must be non-negative");
37+
}
38+
return kilometers / 1.60934;
39+
}
40+
}
41+

0 commit comments

Comments
 (0)