100-days-of-rust/Week-04/Day-22_Marcio-Mellos-Challenge/day22/src/main.rs

23 lines
523 B
Rust
Raw Normal View History

use std::io::{self, Write};
use day22::area_to_fields;
fn main() {
let mut buffer = String::new();
print!("Insert the deforested area in km2: ");
io::stdout().flush().expect("Failed to flush stdout");
io::stdin()
.read_line(&mut buffer)
.expect("Failed to read line");
let area = buffer.trim().parse().expect("The area must be an integer");
let fields = area_to_fields(area);
println!(
"{} km2 is equivalent to {:.3} football fields",
area, fields
);
}