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

[LAB2-Exercise] Calculate body mass index (BMI)

void setup()
{
  size(500,500);
}

float ht = 0;
float BMI = 0;
float H = 0;
void draw()
{
  draw_calculateBMI(50,180,H,ht,BMI);
}

void draw_calculateBMI(float W ,float h ,float H ,float ht ,float BMI)
{
  background(0);
  ht = h / 100.00;
  H =  sq(ht) ;
  BMI = W/H;
  textSize(20);
  text("Weight(kg) ="+nfc(W,2),200,100);
  text("Height(cm) ="+nfc(h,2),200,200);
  text("Height(m) ="+nfc(ht,2),200,300);
  text("BMI ="+nfc(BMI,2),200,400);
}

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

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