println("The handsome stranger said,\n\"My name is Kim, Paul Kim.\"");
int
double (would accept float)
char
illegal, exponent for E notation must be int
char
String
String
float
illegal, should be '\''
illegal, only 1 char allowed inside char
long
illegal, comma not allowed
short
int
byte
long
0.000877
299.04
-44300.0
-0.0023
a) illegal, starts with a number
b) doesn't follow convention since starts with a capital
c) doesn't follow convention since uses currency symbol ($)
e) illegal, space is not allowed
f) illegal, reserved word
b, e, f
x: 0.0093y: -0.003
first is 5
second is -77
void setup()
/* another mess */
{
int i = 7, j = 3;
print("Smaller is " + i);
println(" Larger is " + j);
}
void setup()
{
String s;
char c;
int i;
float f;
s = getString("Enter a string");
c = getChar("Enter a char");
i = getInt("Enter an int");
f = getFloat("Enter a float");
println("The string was " + s);
println("The char was " + c);
println("The int was " + i);
println("The float was " + f);
}
size(500,500);
// the rectangle
stroke(255,0,0);
fill(255,0,0);
rect(400,400,100,100);
//the circle
stroke(0,255,0);
fill(0,255,0);
ellipse(50,50,100,100);
// the triangle
stroke(0);
fill(0,0,255);
beginShape();
vertex(150,150);
vertex(150,250);
vertex(300,200);
endShape(CLOSE);
or if you wanted to use the predefined colours (in another tab):
void setup()
{
size(500,500);
}
void draw()
{
// the rectangle
stroke(RED);
fill(RED);
rect(400,400,100,100);
//the circle
stroke(GREEN);
fill(GREEN);
ellipse(50,50,100,100);
// the triangle
stroke(BLACK);
fill(BLUE);
beginShape();
vertex(150,150);
vertex(150,250);
vertex(300,200);
endShape(CLOSE);
}