fix: ✏️ typos and compiler warnings

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-06-17 18:19:36 +03:00
parent 82c2fb8883
commit 528969944d
17 changed files with 578 additions and 632 deletions

View file

@ -1,52 +1,45 @@
use std::io;
fn get_input() -> i32
{
loop
{
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("Failed to read line");
match input.trim().parse()
{
Ok(num) => return num,
Err(_) =>
{
println!("Expected Valid Number");
}
};
fn get_input() -> i32 {
loop {
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("Failed to read line");
match input.trim().parse() {
Ok(num) => return num,
Err(_) => {
println!("Expected Valid Number");
}
};
}
fn main()
{
println!("Hello, world!");
}
fn main() {
println!("Hello, world!");
println!("1) Fahrenheit to Celsius\n2) Celsius to Fahrenheit");
let mut selection;
let mut b = true;
while b
{
println!("1) Fahrenheit to Celsius\n2) Celsius to Fahrenheit");
let mut selection;
let mut b = true;
while b {
selection = get_input();
match selection {
1 => {
println!("Fahrenheit Value = ↓");
selection = get_input();
match selection
{
1 =>
{
println!("Fahrenheit Value = ↓");
selection = get_input();
println!("Celsius Value = {}", (selection-32) as f32*5.0/9.0);
b = false;
},
2 =>
{
println!("Celsius Value = ↓");
selection = get_input();
println!("Fahrenheit Value = {}", (selection as f32*9.0/5.0)+32.0);
b = false;
},
_ =>
{
println!("Expected Valid Value");
},
}
println!("Celsius Value = {}", (selection - 32) as f32 * 5.0 / 9.0);
b = false;
}
2 => {
println!("Celsius Value = ↓");
selection = get_input();
println!(
"Fahrenheit Value = {}",
(selection as f32 * 9.0 / 5.0) + 32.0
);
b = false;
}
_ => {
println!("Expected Valid Value");
}
}
}
}