[Example] - Adding a fahrenheit to celsius cli program
This commit is contained in:
parent
4100832f8c
commit
c77249b6c8
6
fahrenheit_to_celsius/Cargo.toml
Normal file
6
fahrenheit_to_celsius/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "fahrenheit_to_celsius"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
10
fahrenheit_to_celsius/src/main.rs
Normal file
10
fahrenheit_to_celsius/src/main.rs
Normal file
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user