23 lines
496 B
Rust
23 lines
496 B
Rust
|
use std::io;
|
||
|
|
||
|
fn main() {
|
||
|
println!("Fahrenheit to Celsius Converter");
|
||
|
println!("Enter temperature in Fahrenheit");
|
||
|
|
||
|
let mut temp = String::new();
|
||
|
|
||
|
io::stdin().read_line(&mut temp)
|
||
|
.expect("Failed to read line");
|
||
|
|
||
|
let input_temp: f64 = temp.trim().parse()
|
||
|
.expect("Input must be a number");
|
||
|
|
||
|
let converted = f_to_c(input_temp);
|
||
|
|
||
|
println!("{}°F is {}°C", input_temp, converted);
|
||
|
}
|
||
|
|
||
|
fn f_to_c(fahrenheit: f64) -> f64 {
|
||
|
(fahrenheit - 32.0) / 1.8
|
||
|
}
|