[Example] - Adding a fahrenheit to celsius cli program

This commit is contained in:
Adnan Ioricce 2024-12-27 13:21:01 -03:00
parent 4100832f8c
commit c77249b6c8
2 changed files with 16 additions and 0 deletions

@ -0,0 +1,6 @@
[package]
name = "fahrenheit_to_celsius"
version = "0.1.0"
edition = "2021"
[dependencies]

@ -0,0 +1,10 @@
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let farenheight_input:String = args[1].clone();
let farenheight:f32 = farenheight_input
.parse()
.expect("No input entered");
let celsius = (farenheight - 32.0) * (5.0 / 9.0);
println!("F = {}, C = {}",farenheight,celsius);
}