Building Software Systems I & II
&
Computer Fundamentals
By Thakdanai Khunsaen
OS : Ubuntu GNOME 17.04 64-bit
วันอาทิตย์ที่ 30 สิงหาคม พ.ศ. 2558
Lab2-Circle(Function)
int posX = 25, posY = 50;
int space = 50;
float rad = 15;
void setup(){
size(600,250);
background(#FFCCCC);
float dia = cal_dia(rad);
float cir = cal_cir(rad);
float area = cal_area(rad);
fill(#FF0000);
textSize(30);
text("Radius = "+rad,posX, posY);
text("Diameter = "+dia,posX, posY+space);
text("Area = "+area,posX, posY+space*2);
text("Circumference = " +cir,posX, posY+space*3);
}
float cal_cir(float rad){
float cir;
cir = 2*PI*rad;
return cir;
}
float cal_area(float rad){
float area;
area = PI*rad*rad;
return area;
}
flaot cal_dia(float rad){
float dia;
dia = rad*2;
return dia;
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น