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

Lab 2 : Function BMI

 
void setup(){
  size(300,200);
 
  float myWeight=50;
  float myHeight=160;

  float myBMI=BMI(myHeight,myWeight);
 
  textAlign(CENTER);              //text
  textSize(20);
  fill(#ffffff);
  text("Height = "+myHeight,150,50);
  text("Weight = "+myWeight,150,100);
  textAlign(LEFT);
  text("Body Mass Index = "+myBMI,20,150);
 
}

float BMI(float myHeight,float myWeight){
  float Height_M=myHeight/100;
  float myBMI=myWeight/(Height_M*Height_M);
  return myBMI;
}

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

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