Circle's Calculation by Function
//Circle's Calculationint posx=100;
int posy=100;
int dm=160 ;//diameter
void setup() {
size(500, 500);
circle(100, 100);
calculation();
}
void circle(int posx, int posy) {
background(#FC66C1);//pink <3
ellipse(posx, posy, dm, dm);//example
}
void calculation() {
float r=dm/2;//radius
float r_2=r*r;//radius square
float A=3.14*r_2;//area
float cf=2*(3.14)*r;//circumference
//terminal output
println("Value of circle's area = "+A);
print("Value of circumference's circle = "+cf);
textSize(24);//text size
text("Circumference's circle = "+cf+" m.", 30, 400);
text("Area's circle = "+A+" m^2.", 30, 350);
text("Diameter's circle = "+dm+" m.", 30, 250);
text("Radius's circle = "+r+" m.", 30, 300);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น