BMI Calculator | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

BMI Calculator

Just wondering what's wrong with this code... as its showing as "no Output" as a result. import java.util.Scanner; public calss BMI{ public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); double height; double weight; double BMIValue; //Input Height System.out.println("Enter you height just the feet: "); height = keyboard.nextDouble(); System.out.println("Enter you height just the inches: "); double inches=keyboard.nextDouble(); //Conversion to cm height=height+inches/12; //Input Weight System.out.println("Enter your weight in pounds: "); weight=keyboard.nextDouble(); // conversion to Kg weight=weight/2.2; BMIValue = weight/height*height; System.out.println(BMI); } }

17th Jul 2018, 1:09 AM
Farhan Jamil
2 Respostas
+ 2
https://code.sololearn.com/coC3v8P5Fzf2/#java import java.util.Scanner; public class BMI{ // ERROR 1: class had a typo public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); double height; double weight; double BMIValue; //Input Height System.out.println("Enter you height just the feet: "); height = keyboard.nextDouble(); System.out.println("Enter you height just the inches: "); double inches=keyboard.nextDouble(); //Conversion to cm height=height+inches/12; //Input Weight System.out.println("Enter your weight in pounds: "); weight=keyboard.nextDouble(); // conversion to Kg weight=weight/2.2; BMIValue = weight/height*height; System.out.println(BMIValue); // ERROR 2: BMI should be BMIValue } } ^That should do it. You had a typo in the word 'class' at the top and at the bottom you had BMI instead of BMIValue. I didn't verify the logic side though, so that's on you. ;)
17th Jul 2018, 1:19 AM
Fata1 Err0r
Fata1 Err0r - avatar
0
#your code goes here weight = float(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') elif bmi >= 30: print('Obesity') Copy and paste my answer If it is right vote me
19th Aug 2021, 7:16 AM
Sariga.S