Body Mass Index(BMI)

 Body Mass Index(BMI)

Problem Description


Write a Java program to compute body mass index (BMI).


Test Data

Input weight in pounds: 452

Input height in inches: 72


Expected Output :

Body Mass Index is 61.30159143458721


Note:


Use Double Data Type and output statement in String.format("%.02f",variable name)


Solution,


import java.util.Scanner;

import java.io.*;

public class TestClass {

public static void main(String[] args) { 

Scanner sc= new Scanner(System.in); 

double weight = sc.nextDouble();

double inches = sc.nextDouble();

double BMI = weight * 0.45359237 / (inches * 0.0254 * inches * 0.0254);

String BMIR = String.format ("%,.2f", BMI);

  System.out.print(BMIR);

    }

Post a Comment

0 Comments