index : temp_converter
Convert temperature degres
about summary refs log tree commit diff

Diffstat (limited to 'src/main.rs')

-rw-r--r-- src/main.rs 22
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 12579a8..d31aff6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,8 +9,8 @@

    println!("Celsius ---> Fahrenheit: Press 2");

    let mut direction = String::new(); 
    let mut start_temp = String::new(); 
    let mut direction = String::new();
    let mut start_temp = String::new();

    io::stdin()
        .read_line(&mut direction)
@@ -27,14 +27,12 @@

    let start_temp: f64 = start_temp.trim().parse().expect("Please type a number!");
    println!("You entered {start_temp}");
    
        if direction == 1 {
            let converted_temp: f64 = (start_temp - 32.0) / 1.8;
            println!("{start_temp}F is {converted_temp}C");
        } else if direction == 2 {
            let converted_temp: f64 = (start_temp * 1.8) + 32.0;
            println!("{start_temp}C is {converted_temp}F");
        }
}   


    if direction == 1 {
        let converted_temp: f64 = (start_temp - 32.0) / 1.8;
        println!("{start_temp}F is {converted_temp}C");
    } else if direction == 2 {
        let converted_temp: f64 = (start_temp * 1.8) + 32.0;
        println!("{start_temp}C is {converted_temp}F");
    }
}