0

I am making a simple BMI calculator to practice Java formatting and such and forth, but every time I run the code, I input weight and height and it returns me with "0.0"! I use eclipse and it says nothing is wrong with the code. Please help? PS: Sorry for newb

import java.util.Scanner;
public class Main {
static Scanner input = new Scanner(System.in);
    public static void main(String[] args) {

        //Variables
        System.out.println("Please enter your height in inches: ");
        int height = input.nextInt();
        System.out.println("Please enter your weight in pounds: ");
        int weight = input.nextInt();

 //BMI Calcs
 int newHeight = height*height;
 double initBMI = weight/newHeight;
 double BMI = 703*initBMI;
 System.out.println(BMI);
    }
}
  • I executed your code here https://ideone.com/CWIpxP with inputs 6 and 89 as height and weight . And it doesnt give 0.0. PLease check once at the link – Rudrani Angira Jun 27 '16 at 17:43
  • Also I think you should make height and weight as double instead of int and then make changes accordingly. – Rudrani Angira Jun 27 '16 at 17:44

0 Answers0