This program will generate a random coordinate….

$15.00

Category:

Description

This program will generate a random coordinate, in which the x and y value is between 1 and 200
Then it will generate 20 other points and determine which point is the closest and furthest from
original point. Then it will calculate the distance from the original point to both points.
Algorithm:
1) Generate a random number between 1 and 200 for originalX
2) Generate a random number between 1 and 200 for originalY
3) Generate 20 random number between 1 and 200 for an array of X’s
4) Generate 20 random number between 1 and 200 for an array of Y’s
5) Calculating the distance using for formula provided below
d2 = (x2 – x1)^2 + (y2 – y1)^2
and storing all those distances in an array
6) To find the min, set min = distance[0], and compare it to the first distance,
if distance[0] < min, then set distance[0] to min, and keep going through the distance array
7) To find the max, set max = distance[0], and compare it to the first distance,
if distance[0] max, then set distance[0] to max, and keep going through the distance array
8) Output the original point(x,y)
9) Output the min (Closest Distance) with its coordinate
10) Output the max (Furthest Distance) with its coordinate