-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment1.java
30 lines (28 loc) · 925 Bytes
/
Assignment1.java
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
/**
Assignment number 1
**/
import java.util.Scanner;
public class Assignment1
{
public Assignment1()
{
final double POUND = 0.45359237;
final double INCH = 0.0254;
double weightPound,heightInches,squareHeigth,BMI;
Scanner sc = new Scanner(System.in);
System.out.print("Enter weight in pounds: ");
double weight = sc.nextDouble();
System.out.print("Enter height in inches: ");
double height = sc.nextDouble();
weightPound = weight * POUND; //converting pound to kg
heightInches = height * INCH; //converting inch in meter
squareHeigth = heightInches * heightInches;
BMI = weightPound / squareHeigth;
System.out.printf("BMI is %.4f",BMI);
System.out.println();
}
public static void main(String[] hassan)
{
new Assignment1();
}//main
}//class