Question: tep 2 . Figure out which points are in the circle Let's add an if statement to the program so that points inside the circle

tep 2. Figure out which points are in the circle
Let's add an if statement to the program so that points inside the circle are gray and points outside it are black.
First, delete the reference to drawPoint(x,y,color1);
Now copy the code below and change the "something" and "something else" to some formula that will detect if the random point (x,y) is within the circle:
if ( something < something else){
drawPoint(x,y,color2);
} else {
drawPoint(x,y,color1);
}
Advice #1: In the code use sqrt() for
Advice #2: Use x*x instead of x^2 it's a long story why x^2 usually doesn't work.
Advice #3: To make things easier the code defines the center of the circle is at x =0, y =0. That makes the formula for the distance between the point (x,y) and the origin rather simple.
Advice #4: Use the diagram below for help:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!