Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author hypemonkieboi
- */
- public class BMICalculator {
- //define instance variables or fields or attributes
- private String name;
- private double weight;
- private double height;
- public BMICalculator(String name, double weight, double height)
- {
- this.name = name;
- this.weight = weight;
- this.height = height;
- }
- public String getName()
- {
- return name;
- }
- public double getWeight()
- {
- return weight;
- }
- public double getHeight()
- {
- return height;
- }
- public void setName(String n)
- {
- name = n;
- }
- public void setweight(double w)
- {
- weight = w;
- }
- public void setHeight(double h)
- {
- height = h;
- }
- public String calculateBMIandPrintCategory(String n, double w, double h) {
- double bmi = (weight / (height * height)) * 703;
- String bmiCategory = "";//assign an empty string
- if(bmi >= 40)
- {
- bmiCategory = "Morbid Obese";
- }
- else if(bmi > 35 && bmi < 40)
- {
- bmiCategory = "Severely Obese";
- }
- else if (bmi > 30 && bmi < 35)
- {
- bmiCategory = "Obese";
- }
- else if(bmi > 25 && bmi < 30)
- {
- bmiCategory = "Overweight";
- }
- else if (bmi > 18.5 && bmi < 25)
- {
- bmiCategory = "Normal";
- }
- else
- {
- bmiCategory = "Underweight";
- }
- return bmiCategory;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement