+ 1

BMI Calculator

Hello. Why after asuccessful test cases, task wasn't passed successfully? I may show screens of my program. It worked properly. My code weight=int(input()) height=float(input()) BMI=(weight/height**2) if BMI < 18.5: print ("Underweight") elif BMI <= 18.5 and BMI < 25: print ("Normal") elif BMI >= 25 and BMI < 30: print ("Owerweight") elif BMI > 30: print ("Obesity")

17th Feb 2022, 1:37 PM
Людмила Камінська
12 Answers
+ 8
Python the_height = float(input("Enter the height in cm: ")) the_weight = float(input("Enter the weight in kg: ")) # defining a function for BMI the_BMI = the_weight / (the_height/100)**2 # printing the BMI print("Your Body Mass Index is", the_BMI) # using the if-elif-else conditions if the_BMI <= 18.5: print("Oops! You are underweight.") elif the_BMI <= 24.9: print("Awesome! You are healthy.") elif the_BMI <= 29.9: the_print("Eee! You are over weight.") else: print("Seesh! You are obese.") java import java.util.Scanner; public class Example { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Input weight in kilogram: "); double weight = sc.nextDouble(); System.out.print("\nInput height in meters: "); double height = sc.nextDouble(); double BMI = weight / (height * height); System.out.print("\nThe Body Mass Index (BMI) is " + BMI + " kg/m2"); } }
17th Feb 2022, 3:37 PM
Vaibhav
Vaibhav - avatar
+ 3
print("Overweight")
17th Feb 2022, 2:56 PM
Simba
Simba - avatar
+ 1
Людмила Камінська You are using BMI <= 18.5 and ... instead of BMI >= 18.5 .... in second if edit : spell check in "overweight"
17th Feb 2022, 2:23 PM
Jayakrishna 🇮🇳
0
Can you share screens? edit: code added!
17th Feb 2022, 1:42 PM
Jayakrishna 🇮🇳
0
Screen by the link https://prnt.sc/26xsir9 Also, I can share code weight=int(input()) height=float(input()) BMI=(weight/height**2) if BMI < 18.5: print ("Underweight") elif BMI <= 18.5 and BMI < 25: print ("Normal") elif BMI >= 25 and BMI < 30: print ("Owerweight") elif BMI > 30: print ("Obesity")
17th Feb 2022, 2:18 PM
Людмила Камінська
0
Thank you very much for your help, I fixed but still doesn't pass test case 3 https://prnt.sc/26xt2dk
17th Feb 2022, 2:46 PM
Людмила Камінська
0
works !...
17th Feb 2022, 3:33 PM
Людмила Камінська
0
Your equality sign is wrong here,try to match from mine weight=int(input()) height=float(input()) bmi=weight/(height**2) if bmi < 18.5: print("Underweight") elif bmi < 25: print("Normal") elif bmi < 30: print("Overweight") else: print("Obesity")
18th Feb 2022, 6:16 AM
Lucky Kumar
0
At line 13 u wrote:-("Owerweight") And the write word us:-("Overweight ") If u write this so ur done will pass all tests!
19th Feb 2022, 1:14 PM
Alz_47 YT
Alz_47 YT - avatar
0
#Operador // is the solution.. peso = float(input()) altura = float(input()) bmi = peso // altura**2 if bmi < 18.5: print ("Underweight") elif (bmi == 18.5) or (bmi <= 24.9): print ("Normal") elif (bmi == 25) or (bmi <= 29.9): print ("Overweight") else: print ("Obesity")
19th Feb 2022, 1:22 PM
Andres cedeño
Andres cedeño - avatar
0
It worked in me: #your code goes here weight = int(input()); height = float(input()); bmi = weight/(height**2) if bmi<18.5: print('Underweight') elif bmi>=18.5 and bmi<25: print("Normal") elif bmi>=25 and bmi<30: print('Overweight') else: print('Obesity')
11th May 2022, 5:34 PM
MYusuf
MYusuf - avatar