//K. Thanapat
void setup(){
size(400 ,200);
background(0 ,0 ,255);
float weight = 50;
float height = 170;
float meterHeight = height/100;
float bmi = cal(meterHeight ,weight); //ประกาศฟังก์ชัน
//ตัวอักษร
textSize(25);
text("Your Height = " +height ,50 ,50);
text("Your Weight =" +weight ,50 ,110);
text("Your BMI =" +bmi ,5 ,170);
}
//เรียกใช้ฟังก์ชัน
float cal(float meterHeight ,float weight){
float bmi;
bmi = weight/(meterHeight*meterHeight);
return bmi;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น