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:
// 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();
// While we need to make more spots, do this...
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.
That works. But this?