Facebook
From violeng mam, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 85
  1. size(450,400);
  2.  
  3. // 2,4..
  4. int countEven = 0;
  5. int countEvenDivWith5 = 0;
  6. int countOther = 0;
  7. int initial = 15;
  8.  
  9. textSize(20);
  10. int xOther = 0;
  11. int xEven = 0;
  12. int xEven5 = 0;
  13. for (int i=0; i <=initial; i++){
  14.   if (i%2 == 0 && i%5 == 0){
  15.     xEven5 = xEven5 + 25;
  16.     fill(0, 255, 0);
  17.     text(i, xEven5, 200);
  18.     countEvenDivWith5 = countEvenDivWith5 + 1;
  19.     xEven = xEven + 25;
  20.     fill(255, 0, 0);
  21.     text(i, xEven, 100);
  22.     countEven = countEven + 1;
  23.   } else if (i%2 == 0) {
  24.     xEven = xEven + 25;
  25.     fill(255, 0, 0);
  26.     text(i, xEven, 100);
  27.     countEven = countEven + 1;
  28.   } else {
  29.     xOther = xOther + 25;
  30.     fill(0,0,255);
  31.     text(i, xOther, 300);
  32.     countOther = countOther + 1;
  33.   }  
  34. }
  35. fill(0);
  36. text("With number from 0 to " + initial + ":", 25, 20);
  37. fill(255, 0, 0);
  38. text("The count of even numbers: " + countEven, 25, 70);
  39. line(0, 120, width, 120);
  40. fill(0,255,0);
  41. text("The count of even and it is also divisible by 5: " + countEvenDivWith5, 25, 170);
  42. line(0, 220, width, 220);
  43. fill(0,0,255);
  44. text("The count of other (odd) numbers: " + countOther, 25, 270);
  45. save("activity11.png");