Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn bmi(weight: u32, height: f32) -> &'static str {
- let bmi: f64 = (weight as f64) / (height as f64).powf(2.0);
- let result: &'static str =
- if bmi <= 18.5 { "Underweight" } else
- if bmi <= 25.0 { "Normal" } else
- if bmi <= 30.0 { "Overweight" } else
- if bmi > 30.0 { "Obese" } else
- { "default" };
- return result
- }
- #[test]
- fn basic_unit_test() {
- assert_eq!(bmi(80, 1.80), "Normal");
- }
Add Comment
Please, Sign In to add comment