Pacman[] pac;
void setup()
{
size(400, 400);
pac = new Pacman[30];
for (int i=0; i<pac.length; i++)
{
pac[i] = new Pacman(random(256), random(256), random(256), random(0, 1), random(width));
}
}
void draw()
{
background(0);
for (int i=0; i<pac.length; i++)
{
pac[i].changeColor();
pac[i].move();
pac[i].drawPac((i+1)*20);
}
}
class Pacman
{
float r, g, b;
float speed;
float x;
int changeMouth = 0;
boolean flag = false;
Pacman(float r1, float g1, float b1, float s, float loc)
{
r = r1;
g = g1;
b = b1;
speed = s;
x = loc;
}
void changeColor()
{
fill(r, g, b);
}
void move()
{
x += speed;
if (x > width)
{
x = 0;
}
}
void drawPac(int y)
{
if (flag)
{
ellipse(x, y, 20, 20);
}
else
{
arc(x, y, 20, 20, .52, 5.76);
}
changeMouth++;
if (changeMouth % 6 == 0)
{
changeFlag();
}
}
void changeFlag()
{
if (flag)
{
flag = false;
}
else
{
flag = true;
}
}
}
Write a program that multiplies three numbers together and prints the results to the screen. Do this for 5 sets of numbers. Use a function that returns the product of the three numbers to do this.
You may have lines like this in your code: