วันอาทิตย์ที่ 30 สิงหาคม พ.ศ. 2558

Lab 2 : Calculate body mass index (BMI) (function)


  float weight;
  float Hcm;
  float Hm;
  float bmi;
void setup() {
  size(300, 300);
  background(255);
  //setting variable
  weight=39;         //weight-kilogram
  Hcm=151;           //height-centimeter
  //calculate
  Hm=Hcm/100;
  bmi=weight/(Hm*Hm);
  //function call
  calculate_bmi(5,20);

}
void calculate_bmi(int x,int y) {
  //result
  fill(0);
  textSize(20);
  text("Weight : "+weight,x,y);
  text("Height(centimeter) : "+Hcm,x,y+30);
  text("BMI : "+bmi,x,y+60);
}


ไม่มีความคิดเห็น:

แสดงความคิดเห็น