/* 6.914, Example 1.1 else, print/println, and casting to int 0) Use 'else' after your 'if' clauses to give code that should run if the conditional statement to if is false. You can also use else to specify a series of conditional statements. For instance, if you have a variable x that you want to increment in some cases (like when it's less than 50), decrement in others (like when it's greater than 200) and add a random number between -10 and 10 to otherwise, you could use the code given below... 1) print and println will print text to the black box under the coding window. println will include a carriage return at the end, so the next text will appear on a new line; print will not include a carriage return. use this syntax: println("hello world"); print("hello world"); 2) The numbers returned by random() will be floating-point decimals (floats.) In order to get integers, you should cast to an int, with this syntax: int a = int(random(5, 10)); */ int x = 75; void setup(){ size(250, 100); } void draw(){ background(0); rect(x, 50, 10, 10); print("The value of x is: "); // next text afterwards *WON'T* be on new line println(x); // next text will be on new line if (x < 50){ x++; } else if (x > 200){ x--; } else{ x += int(random(-10, 10)); } }