fix: ✏️ typos and compiler warnings
This commit is contained in:
parent
82c2fb8883
commit
528969944d
17 changed files with 578 additions and 632 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue