Migration from GitHub

This commit is contained in:
rarmknecht
2025-12-19 23:39:55 -06:00
commit 90a79b7923
25 changed files with 3017 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
use std::io;
fn main() {
println!("Welcome to Temp Converter!");
// Loop the Main Menu
loop {
println!("Chose:\n\t[1] F to C\n\t[2] C to F\n\t[3] Quit");
let mut choice = String::new();
io::stdin()
.read_line(&mut choice)
.expect("Failed to read line");
let choice = choice.trim();
match choice {
"1" => {
println!("F to C it is!");
let c = f_to_c(get_temp());
println!("That's {} in Celsius", c);
}
"2" => {
println!("C to F it is!");
let f = c_to_f(get_temp());
println!("That's {} in Fahrenheit", f);
}
"3" => {
println!("Good Bye!");
break;
}
_ => continue,
}
}
}
fn f_to_c(f: f64) -> f64 {
(f - 32.0) * (5.0/9.0)
}
fn c_to_f(c: f64) -> f64 {
(c * (9.0/5.0)) + 32.0
}
fn get_temp() -> f64 {
loop {
println!("Enter your starting temp:");
let mut temp = String::new();
io::stdin()
.read_line(&mut temp)
.expect("Failed to read line");
let temp = temp.trim();
let f : f64 = match temp.parse() {
Ok(num) => num,
Err(_) => continue,
};
return f
}
}