diff --git a/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.lock b/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.lock new file mode 100644 index 0000000..b829f7f --- /dev/null +++ b/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "convert_ages_to_days" +version = "0.1.0" diff --git a/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.toml b/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.toml new file mode 100644 index 0000000..5266e2a --- /dev/null +++ b/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "convert_ages_to_days" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/src/main.rs b/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/src/main.rs new file mode 100644 index 0000000..543888d --- /dev/null +++ b/Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/src/main.rs @@ -0,0 +1,27 @@ +use std::io; + +fn main() { + + loop { + + println!("Please input your age in years!"); + + let mut guess = String::new(); + + + io::stdin() + .read_line(&mut guess) + .expect("Could not read age. Make you an integer is used."); + + let guess: u32 = match guess.trim().parse() { + Ok(num) => num, + Err(_) => continue, + }; + + let age: u32 = guess * 365; + + println!("You are roughly {age} days old!") + + } + +}