Day 01 Project completed
This commit is contained in:
parent
225ea99314
commit
8939e66885
7
Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.lock
generated
Normal file
7
Week-01/Day-01_Convert-Ages-To-Days/convert_ages_to_days/Cargo.lock
generated
Normal file
@ -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"
|
@ -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]
|
@ -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!")
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user