awk Exercise 4Save the following data in a file named coordinates.txt.
A,0,0;B,3,4 C,4,7;D,2,9 E,8,2;F,0,6
Each line of the file contains the name of a point and its
x-y coordinates, a semicolon, then the name of a second point and its
x-y coordinates.
Write an awk script that will do the following:
This calculation must be done in a user-defined function
named distance. This function will take four arguments
for the x and y coordinates of the two points.
This calculation must be done in a user-defined function
named city_block. This function will take four arguments
for the x- and y- coordinates of the two points.
Print the point names and their coordinates; this will be done
by calling a user-defined function named show_point twice,
once for each point. The point names and coordinates will be followed
by the distances. The show_point function will take three
arguments: the point name, the x-coordinate and the y-coordinate.
Your script must not be tied to this specific data. If the numbers change, or if records are added or deleted, your script must still produce the correct results.
After you have processed all the records, generate two random numbers in the range 0 to 10 (inclusive). These will be coordinates for point "Q". Then generate two random numbers in the range 0 to 10 (inclusive) as point "R". Print the coordinates for these new points, then calculate and print the distance and city block distance for these new, random points.
Print the output to look like the following. Print only three numbers after the decimal point.
From A (0, 0) to B (3, 4): actual distance 5.000; city block distance 7 From C (4, 7) to D (2, 9): actual distance 2.828; city block distance 4 From E (8, 2) to F (0, 6): actual distance 8.944; city block distance 12 From Q (9, 2) to R (3, 7): actual distance 7.810; city block distance 11
Name your file for part 1 in the form lastname_firstname_coordinates.awk and email it to the instructor.