Speed up development with full-stack environments for every branch.

Learn More

BMI Calculator ( Metric ) [Java, Formula and Basic]

Forked from Basic Java Example.

1650 Runs 10553 Views 2953 Copies
Saved

Saved

Faisal0sal 1

Faisal0sal
published 2 years ago

import java.util.Scanner;

public class HelloWorld {
  public static void main(String[] args) {
    Scanner stdin;
    double weight;
    double height;
    double result;
    stdin = new Scanner(System.in);
    System.out.println("Welcome, can you enter your Weight?");
    weight = stdin.nextInt();
    System.out.println("You can enter your Height");
    height = stdin.nextInt();
    // BMI formula ( weight / height * height )
    result = ( weight / (height * height)) * 10000;
    System.out.printf("%n Your weight in kilos: " + weight);
    System.out.printf("%n Your height: " + height);
    System.out.printf("%n Your BMI is " + Math.round(result) + ".");
  }
}
 

Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).