Question: Here are the specifications for this problem: Use a 5 0 0 x 5 0 0 canvas. Usually the canvas size is pretty arbitrary, but
Here are the specifications for this problem:
Use a x canvas. Usually the canvas size is pretty arbitrary, but this time it will be important to
demonstrate your understanding of this problem.
Draw the head and body of the lady bug. You are free to add more details to the drawing if you like,
so long as you are still meeting the criteria outlined here.
Use a whileloop to draw N small black spots circles of diameter on the bug. The example above
uses N of but your program should work for any value of N It is okay if the circles sometimes
overlap with each other, but they should all be completely on the bug.
Heres the trick: your spots need to be at random locations. To generate random coordinates for a single
spot, use these two lines of code:
x int random
y int random
The random function simply returns a random number within the specified bounds, so in this case, x
and y will be random coordinates on your x canvas. The problem is that the bug doesnt fill the
whole canvas, so sometimes the random coordinates will be no good. That simply means youll have to not draw a spot at those coordinates and try again. Thats why you need to use a whileloop for this problem,
because you dont know how long it will take to generate valid coordinates for N spots on the bug
Hint: Make sure to take the diameterradius of the holes into account when checking if the random coor
dinates are valid; your holes need to be completely on the bug!
Hint: You can use your code or the solution code for insidecircle from A to help you do this check
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
