วันจันทร์ที่ 7 กันยายน พ.ศ. 2558

Lab 3 - Power of Ten


void setup() {
  size (400, 400);
  background (255);
  fill(255,0,0);
  textSize(30);
  textAlign(CENTER);
  text("Power of Ten",width/2,50);
  
}

void draw() {
  power_ten(6);
  power_ten(5);
  power_ten(12);
  power_ten(15);
  power_ten(18);
  power_ten(21);
  power_ten(30);
  power_ten(100);
  
  
}

void power_ten(int x){
  
  fill(0);
  textSize(15);
  if(x==6||x==9||x==12||x==15||x==18||x==21||x==30||x==100){
    if(x==6){
    text("10^"+x+"= Million",width/2,height/2-70);
    }
    if(x==9){
    text("10^"+x+"= Billion",width/2,height/2-50);
    }
    if(x==12){
    text("10^"+x+"= Trillion",width/2,height/2-30);
    } 
    if(x==15){
    text("10^"+x+"= Quadrillion",width/2,height/2-10);
    }
    if(x==18){
    text("10^"+x+"= Quintillion",width/2,height/2+10);
    }
    if(x==21){
    text("10^"+x+"= Sextillion",width/2,height/2+30);
    }
    if(x==30){
    text("10^"+x+"= Nonillion",width/2,height/2+50);
    }
    if(x==100){
    text("10^"+x+"= Googol",width/2,height/2+70);
    }
  } else {
    
    textAlign(CENTER);
    textSize(50);
    
    text("ERROR!!!",width/2,height/2);
  }
  
}

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

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