Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Temperature-conversion/Rust/temperature-conversion.rust
Normal file
21
Task/Temperature-conversion/Rust/temperature-conversion.rust
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
fn main() -> std::io::Result<()> {
|
||||
print!("Enter temperature in Kelvin to convert: ");
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input)?;
|
||||
match input.trim().parse::<f32>() {
|
||||
Ok(kelvin) => {
|
||||
if kelvin < 0.0 {
|
||||
println!("Negative Kelvin values are not acceptable.");
|
||||
} else {
|
||||
println!("{} K", kelvin);
|
||||
println!("{} °C", kelvin - 273.15);
|
||||
println!("{} °F", kelvin * 1.8 - 459.67);
|
||||
println!("{} °R", kelvin * 1.8);
|
||||
}
|
||||
}
|
||||
|
||||
_ => println!("Could not parse the input to a number."),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue