2020-12-24 18:36:08 +00:00
|
|
|
## temperature_conv
|
|
|
|
|
|
|
|
### Instructions
|
|
|
|
|
2022-05-18 14:44:55 +00:00
|
|
|
Write two functions which convert temperatures from `fahrenheit` to `celsius` and the other way around.
|
2020-12-24 18:36:08 +00:00
|
|
|
|
2021-02-03 18:59:38 +00:00
|
|
|
To pass this exercise you must use (9/5) in **both** functions.
|
|
|
|
|
|
|
|
### Expected functions
|
2020-12-24 18:36:08 +00:00
|
|
|
|
|
|
|
```rust
|
2021-02-03 18:59:38 +00:00
|
|
|
pub fn fahrenheit_to_celsius(f: f64) -> f64 {
|
2020-12-24 18:36:08 +00:00
|
|
|
}
|
|
|
|
|
2021-02-03 18:59:38 +00:00
|
|
|
pub fn celsius_to_fahrenheit(c: f64) -> f64 {
|
2020-12-24 18:36:08 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-05-18 14:44:46 +00:00
|
|
|
### Example
|
2020-12-24 18:36:08 +00:00
|
|
|
|
|
|
|
```rust
|
|
|
|
use temperature_conv::*;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
println!("{} F = {} C", -459.67, fahrenheit_to_celsius(-459.67));
|
|
|
|
println!("{} C = {} F", 0.0, celsius_to_fahrenheit(0.0));
|
|
|
|
}
|
|
|
|
```
|
2021-02-03 18:59:38 +00:00
|
|
|
|
|
|
|
And its output:
|
|
|
|
|
|
|
|
```console
|
2021-04-28 09:47:34 +00:00
|
|
|
$ cargo run
|
2021-02-03 18:59:38 +00:00
|
|
|
-459.67 F = -273.15 C
|
|
|
|
0 C = 32 F
|
2021-04-28 09:47:34 +00:00
|
|
|
$
|
2021-02-03 18:59:38 +00:00
|
|
|
```
|