forked from erenuygur/EfficientHouseJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ1.java
More file actions
28 lines (21 loc) · 794 Bytes
/
Q1.java
File metadata and controls
28 lines (21 loc) · 794 Bytes
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
package homeworks.chapter2;
/*
Body Mass Index (BMI) helps in specifying the weight category a person
belongs to, depending on their body weight. BMI is estimated using the following formula:
BMI = Weight in kilograms / (Height in meters)2
Write a program that calculates and outputs the BMI. Assume various input values
wherever required.
*/
public class Q1 {
public static void main(String[] args)
{
double kilogram, meter, bmi;
java.util.Scanner scanner = new java.util.Scanner(System.in);
System.out.println("Kilogram: ");
kilogram = scanner.nextDouble();
System.out.println("Meter: ");
meter = scanner.nextDouble();
bmi = kilogram / (meter * meter);
System.out.printf("Body Mass Index is: %.2f", bmi);
}
}