float [][]region= {
{
0.67, 0.83, 1.22, 1.65, 1.96
} //Bangkok
, {
0.67, 1.11, 1.40, 1.83, 2.09
}//Northern Regioun
};
String[]Age= {
"15-19", "20-24", "25-29", "30-34", "35-39"
};
float average=0;
int count =0;
int x=50;
int y =400;
int i=0;
float max= region[0][0];
float min= region[0][0];
void setup() {
size(500, 500);
background(51, 0, 0);
///head
stroke(255);
strokeWeight (3);
line(x, y, x, y-320);
line(x, y, x+420, y);
text("NUMBER OF CHILDEN EVER BORN", 35, 35);
while (count<Age.length) {
if (region[i][count]<min) {
min=region[i][count];
}
if (region[i][count]>max) {
max=region[i][count];
}
if (count==Age.length) {
i=i+1;
}
average = average+region[i][count];
noStroke ();
fill(255, 255, 0);
rect(x+5, y, 30, -region[i][count]*150);
text(region[0][count], x, (y-region[0][count]*150)-10);
fill(255, 0, 0);
rect(x+40, y, 30, -region[i+1][count]*150);
text(region[i+1][count], x+40, (y-region[i+1][count]*150)-10);
fill(255);
text(Age[count], x+20, y+20);
x=x+80;
count=count+1;
}
fill(0, 0, 255);
rect(80, 100, 110, 70);
fill(255);
text("Max is"+" "+max, 90, 120);
text("Min is"+" "+min, 90, 140);
text("Average is"+" "+average/Age.length, 90, 160);
/// data
fill(255);
text("Bangkok", 380, 450);
text("Northern Regioun", 380, 470);
fill(255, 255, 0);
rect(360, 440, 10, 10);
fill(255, 0, 0);
rect(360, 460, 10, 10);
}
From: National Statistical Office
ไม่มีความคิดเห็น:
แสดงความคิดเห็น