Skip to content

Commit 910ecce

Browse files
create financial/price_plus_tax function
1 parent 274ca13 commit 910ecce

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/financial/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mod price_plus_tax;
2+
3+
pub use price_plus_tax::price_plus_tax;

src/financial/price_plus_tax.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub fn price_plus_tax(price: f64, tax_rate: f64) -> f64{
2+
price * (1 as f64 + tax_rate)
3+
}
4+
5+
6+
7+
#[cfg(test)]
8+
mod tests {
9+
use super::*;
10+
11+
#[test]
12+
fn test_price_plus_tax() {
13+
assert_eq!(131.775,price_plus_tax(125.50, 0.05));
14+
assert_eq!( 125.0,price_plus_tax(100.0, 0.25));
15+
}
16+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub mod number_theory;
1919
pub mod searching;
2020
pub mod sorting;
2121
pub mod string;
22+
pub mod financial;
2223

2324
#[cfg(test)]
2425
mod tests {

0 commit comments

Comments
 (0)