-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathBmiCalculator.java
37 lines (34 loc) · 983 Bytes
/
BmiCalculator.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
31
32
33
34
35
36
import java.util.*;
class BMI {
private double weight;
private double height;
private double bmi;
public void setWeight(double weight) {
this.weight = weight;
}
public void setHeight(double height){
this.height=height;
}
public double getWeight(){
return this.weight;
}
public double getHeight(){
return this.height;
}
public double bmiValue(){
return getWeight()/Math.pow(getHeight(),2);
}
}
public class BmiCalculator {
public static void main(String[] args){
BMI sample1=new BMI();
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Height(In meters) : ");
double height=sc.nextDouble();
sample1.setHeight(height);
System.out.print("Enter the Weight(In Kilograms) : ");
double weight=sc.nextDouble();
sample1.setWeight(weight);
System.out.println("The BMI Value is "+ sample1.bmiValue());
}
}