Fun with Judo

We just downloaded Judo last week so I could figure out how to program. Today I decided to make a spot making program. Mary asked for 999,999 spots and it took a long time, so I wondered how many spots my program could make per second. So at first we just tried counting and calculating, but then I realized that we could use a timer instead. Well, maybe Java isn’t perfect, because we got some pretty funny results! I don’t think this is accurate!

This is the code I made up:


void main(){


// declare variables
int icount = 0; // count
int inum; // number
double seconds; // seconds
double persecond; // spots per second


// ask user how many spots
printLine("How many spots would you like?");
inum = readInt();
startTimer();


// While we need to make more spots, do this...
while(icount<inum) {
setColor (randomColor());
fillCircle(randomInt(400), randomInt(300), randomInt(150));
icount = icount+1;
}


// stop timer and make calculations
seconds = stopTimer();
persecond = inum/seconds;
printLine("That took " + seconds + " seconds... that's " + persecond + " spots per second!");
}

This is what I got.

What I expected

That works. But this?

What I got ... INFINITY spots per second?

LOL!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s