int initialValue = 10; // Initial integer value
int redCount = 0; // Counter for red numbers
int greenCount = 0; // Counter for green numbers
int blueCount = 0; // Counter for blue numbers
void setup() {
size(600, 200);
background(255);
// Loop through numbers from 0 to initialValue
for (int i = 0; i <= initialValue; i++) {
// Check conditions using if/else if/else statement
if (i % 2 == 0 && i % 5 == 0) {
fill(0, 255, 0); // Green for even and divisible by 5
greenCount++;
} else if (i % 2 == 0) {
fill(255, 0, 0); // Red for even numbers
redCount++;
} else {
fill(0, 0, 255); // Blue for odd numbers
blueCount++;
}
// Display the number on the canvas
textSize(20);
text(i, 50 + i * 30, 100);
}
// Display the counts at the end of the loop
fill(0);
textSize(16);
text("Red count: " + redCount, 50, 150);
text("Green count: " + greenCount, 200, 150);
text("Blue count: " + blueCount, 350, 150);
save("activity11.png");
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}