BMI's Calculation by Function
//BMI Function
void setup() {
size(300,300);
background(#FF8B8B);//pink
calculation(80,175);
}
void calculation(int w,int h){
float h_2=(h/100.0)*(h/100.0);//Height^2
float BMI=w/h_2;//value of BMI
//terminal output
print("Value Of BMI="+BMI);
//explaining text
textSize(24);//size of text
text("Weight = "+w+" Kg.",30,100);
text("Height = "+h+" cm.",30,140);
text("BMI="+BMI+"",30,180);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น