-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractical_02.java
More file actions
36 lines (27 loc) · 1.2 KB
/
Practical_02.java
File metadata and controls
36 lines (27 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Question := Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in
kilograms and dividing by the square of your height in meters. Write a program that prompts the user
to enter a weight in pounds and height in inches and displays the BMI.
Note:- 1 pound=.45359237 Kg and 1 inch=.0254 meters */
import java.util.Scanner;
public class Practical_02 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Weight in pounds:= ");
float pounds= sc.nextFloat();
float kg=pounds*0.45359237f;
System.out.println( "Weight in kilograms:= "+kg);
System.out.print("Height in inches:= ");
float inches= sc.nextFloat();
float h=inches*0.0254f;
System.out.println("Height in meters:=" + h);
float BMI=kg/(h*h);
System.out.println("Body Mass Index(BMI):= "+BMI);
}
}
/* Output :=
Weight in pounds:= 25
Weight in kilograms:= 11.339809
Height in inches:= 35
Height in meters:=0.889
Body Mass Index(BMI):= 14.348359
*/