23 lines
485 B
Rust
23 lines
485 B
Rust
use std::io;
|
|
|
|
fn main() {
|
|
println!("Celsius to Fahrenheit Converter");
|
|
println!("Enter temperature in Celsius");
|
|
|
|
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 = c_to_f(input_temp);
|
|
|
|
println!("{}°C is {}°F", input_temp, converted);
|
|
}
|
|
|
|
fn c_to_f(celsius: f64) -> f64 {
|
|
celsius * 1.8 + 32.0
|
|
}
|