Day 01 Project completed

This commit is contained in:
Dom Sec 2023-03-27 15:08:35 -04:00 committed by GitHub
parent 225ea99314
commit 8939e66885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View 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"

View File

@ -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]

View File

@ -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!")
}
}