Anonymous user
Currency: Difference between revisions
m
→{{header|Rust}}
(Added Rust solution) |
|||
Line 1,276:
fn main() {
let hamburger = Currency::new(
let milkshake = Currency::new(
let pre_tax = hamburger * 4_000_000_000_000_000 + milkshake * 2;
println!("Price before tax: {}", pre_tax);
Line 1,322:
impl Currency {
fn new(num:
Self {
amount: BigRational::new(((num * 100.0) as i64).into(),
}
}
fn calculate_tax(&self) -> Self {
let tax_val = BigRational::new(765.into(), 100.into());// 7
let amount = (&self.amount * tax_val).ceil() / BigInt::from(100);
Self {
|