-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMI.java
More file actions
51 lines (37 loc) · 1.15 KB
/
BMI.java
File metadata and controls
51 lines (37 loc) · 1.15 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package javaIntroduction;
import java.util.Scanner;
public class BMI {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean isTall;
System.out.println("Enter Name:");
String name = input.nextLine();
System.out.println("Enter age:");
int age = input.nextInt();
System.out.println("Enter Weight(in kg):");
double weight = input.nextDouble();
System.out.println("Enter Height(in cm):");
double height = input.nextDouble();
height = height / 100;//in m
System.out.println("Gender: ");
char gender = input.next().charAt(0);
//metric units
double bmi = weight / (height * height);
//
if(age < 18 && height > (150/100)) {
isTall = true;
}
else {
isTall = false;
}
//outputs to the user
System.out.println();
System.out.println("###############################");
System.out.println("Name: "+name);
System.out.println("Gender: "+gender);
System.out.println("BMI: "+ bmi);
System.out.println("Tall? "+ isTall);
System.out.println();
System.out.println("###############################");
}
}