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 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 drawPointxycolor;
Now copy the code below and change the "something" and "something else" to some formula that will detect if the random point xy is within the circle:
if something something else
drawPointxycolor;
else
drawPointxycolor;
Advice #: In the code use sqrt for
Advice #: Use xx instead of x it's a long story why x usually doesn't work.
Advice #: To make things easier the code defines the center of the circle is at x y That makes the formula for the distance between the point xy and the origin rather simple.
Advice #: Use the diagram below for help:
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
