update temperature version
This commit is contained in:
parent
f830d83b92
commit
090a365d63
3 changed files with 10 additions and 4 deletions
2
temperature/Cargo.lock
generated
2
temperature/Cargo.lock
generated
|
@ -2,5 +2,5 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "temperature"
|
name = "temperature"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "temperature"
|
name = "temperature"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
authors = ["Pecha <petralawson@tuta.io>"]
|
authors = ["Pecha <petralawson@tuta.io>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ fn main() {
|
||||||
loop {
|
loop {
|
||||||
let mut scale = String::new();
|
let mut scale = String::new();
|
||||||
let mut temperature = String::new();
|
let mut temperature = String::new();
|
||||||
let mut o_scale = String::new();
|
|
||||||
|
|
||||||
|
let mut o_scale = String::new();
|
||||||
println!("Please enter a scale to convert from- Farenheit (F) or Celsius (C)");
|
println!("Please enter a scale to convert from- Farenheit (F) or Celsius (C)");
|
||||||
io::stdin().read_line(&mut scale)
|
io::stdin().read_line(&mut scale)
|
||||||
.expect("ALERTA ALERTA ANTIFASCISTA");
|
.expect("ALERTA ALERTA ANTIFASCISTA");
|
||||||
|
@ -24,7 +24,13 @@ fn main() {
|
||||||
println!("Please enter a temperature");
|
println!("Please enter a temperature");
|
||||||
io::stdin().read_line(&mut temperature)
|
io::stdin().read_line(&mut temperature)
|
||||||
.expect("ALERTA ALERTA ANTIFASCISTA");
|
.expect("ALERTA ALERTA ANTIFASCISTA");
|
||||||
let mut temperature: f32 = temperature.trim().parse().unwrap();
|
let mut temperature: f32 = match temperature.trim().parse() {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(_) => {
|
||||||
|
println!("Error: not recognised as a number, please try again.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// [°C] = ([°F] - 32) x 5/9
|
// [°C] = ([°F] - 32) x 5/9
|
||||||
//[°F] = [°C] x 9/5 + 32
|
//[°F] = [°C] x 9/5 + 32
|
||||||
|
|
Loading…
Reference in a new issue