วันเสาร์ที่ 5 กันยายน พ.ศ. 2558

Lab3_Power_of_ten

Power of ten

void setup() {
  size(300, 500);
  background(255);
  draw_number_form(170, 100);
  fill(#0000DD);
  textSize(15);
  //////////////// INPUT VALUE//////////////
  calculate(19);
  //////////////////////////////////////////
}
void draw_number_form(int posX, int posY) {
  fill(0);
  textSize(25);
  text("Power of Ten", 20, 50);

  //// number's word code
  textSize(25);
  text("Number", posX, posY);
  text("Value", 40, 100);
  textSize(20);
  text("Million", posX, posY+40);
  text("Billion", posX, posY+80);
  text("Trillion", posX, posY+120);
  text("Quadrillion", posX, posY+160);
  text("Quintillion", posX, posY+200);
  text("Sextillion", posX, posY+240);
  text("Nonillion", posX, posY+280);
  text("Googol", posX, posY+320);
}
void calculate(int power_number) {
  int posX=40;//position X
  int posY=100;// position y
  text("Value : 10^"+power_number,190,50);
  /////show the input value////
  if (power_number==6) {
    text("10"+"^"+power_number, posX, posY+40);
  } else if (power_number==9) {
    text("10"+"^"+power_number, posX, posY+80);
  } else if (power_number==12) {
    text("10"+"^"+power_number, posX, posY+120);
  } else if (power_number==15) {
    text("10"+"^"+power_number, posX, posY+160);
  } else if (power_number==18) {
    text("10"+"^"+power_number, posX, posY+200);
  } else if (power_number==21) {
    text("10"+"^"+power_number, posX, posY+240);
  } else if (power_number==30) {
    text("10"+"^"+power_number, posX, posY+280);
  } else if (power_number==100) {
    text("10"+"^"+power_number, posX, posY+320);
  } else {
    fill(#DD0000);
    text("The value input doesn't have the word", 10, 480);
  }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น