public/subjects/temperature_conv/README.md

38 lines
614 B
Markdown
Raw Permalink Normal View History

2020-12-24 18:36:08 +00:00
## temperature_conv
### Instructions
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
}
```
### 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
$ cargo run
2021-02-03 18:59:38 +00:00
-459.67 F = -273.15 C
0 C = 32 F
$
2021-02-03 18:59:38 +00:00
```