Java – BMI Calculator

After some exhaustion with writing, university and work I am starting to feel a little more better and motivated to start updating this webpage. I am currently working as an IT-Technician in CGI Portugal branch so I am feeling that it would be a nice side hobby just to update the main page with random stuff that I read, encounter or feel like writing about. In no way does the content reflect my skill levels but they are just some basic repeating of the old stuff. I also feel that It will take more time to manage all these different sites rather than writing the content so whenever I feel I will write in the main page and sometimes in the other pages if I feel obligated because the blog is not a professional one but rather a hobby.


 

 

public class BMI {
 /*
   * Underweight = <18.5
   * Normal weight = 18.5–24.9
      * Overweight = 25–29.9
      * Obesity = BMI of 30 or greater
  */
 private double inches;
 
 private double weight;
 
 private double BMI;

 public BMI (double inches, double weight) {
  this.inches = inches;
  this.weight = weight;
  calculate();
 }
 
 public void calculate() {
  this.BMI = weight / (this.inches * this.inches);
  analysis();
 }
 
 public void analysis() {
  if (this.BMI < 18.5) {
   System.out.println(“You are underweight”);
  }
  else if (this.BMI >= 18.5 && this.BMI < 24.9) {
   System.out.println(“You are normal weight”);
  }
  else if (this.BMI >= 24.9 && this.BMI < 29.9) {
   System.out.println(“You are overweight”);
  }
  else if (this.BMI >= 29.9) {
   System.out.println(“You are obese”);
  }
 }
 /**
  * @return the inches
  */
 public double getInches() {
  return inches;
 }

 /**
  * @param inches the inches to set
  */
 public void setInches(double inches) {
  this.inches = inches;
 }

 /**
  * @return the weight
  */
 public double getWeight() {
  return weight;
 }

 /**
  * @param weight the weight to set
  */
 public void setWeight(double weight) {
  this.weight = weight;
 }

 /**
  * @return the bMI
  */
 public double getBMI() {
  return BMI;
 }

 /**
  * @param bMI the bMI to set
  */
 public void setBMI(double bMI) {
  BMI = bMI;
 }

 /* (non-Javadoc)
  * @see java.lang.Object#toString()
  */
 @Override
 public String toString() {
  return “BMI [inches=” + inches + “, weight=” + weight + “, BMI=” + BMI
    + “]”;
 }
}


public class MainProgram {
 public static void main(String[] args) {
  BMI bmi = new BMI(187,80);
 }
}