/****************************************************************************** * This program checks a traingle to see if it is a right triangle. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ #![allow(dead_code)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] fn main() { let hypotenuse_str:String = Utils.prompt("Hypotenuse: "); let leg1_str:String = Utils.prompt("Leg #1: "); let leg2_str:String = Utils.prompt("Leg #2: "); let hypotenuse:f64 = hypotenuse_str.trim().parse::().unwrap_or(0.f64); let leg1:f64 = leg1_str.trim().parse::().unwrap_or(0.f64); let leg2:f64 = leg2_str.trim().parse::().unwrap_or(0.f64); let is_right_triangle:bool = hypotenuse * hypotenuse == leg1 * leg1 + leg2 * leg2; println!("Triangle is {}a right triangle!", (if is_right_triangle { "" } else { "NOT " })); }