Question: Visual Basic Question 2 (25%) In analytical geometry, a convex polygon can be represented by the Cartesian coordinates x and y of its vertices. Assume

 Visual Basic Question 2 (25%) In analytical geometry, a convex polygon

Visual Basic

Question 2 (25%) In analytical geometry, a convex polygon can be represented by the Cartesian coordinates x and y of its vertices. Assume such data of a polygon are stored in a file called vertices.dat. Each line of the file contains a pair of real numbers (separated by a comma) describing the coordinates of n points (one pair per line). Create a VB Console Application called Polygon according to the following instructions: 1. In Sub Main, declare all necessary variables including an array with the x coordinates of the points, and an array with the y coordinates of the points, etc. Assume static array sizes of Nmax = 20, i.e., allow a maximum of 20 points. The program should stop with an appropriate message if the user supplies a file with more than Nmax data points. The main program should call all Subs and Functions discussed in points 2 to 5 below. Do not use UDTS! 2. Write a Sub Open_File which opens the input file vertices.dat" and reads the coordinates of the points from the input file. 3. Write a Sub Calc_Length which calculates the length of all sides of the polygon. 4. Write a Function Perimeter which calculates the perimeter of the polygon. 5. Write a Sub Output_File which writes the length of all sides and the perimeter into an output file called "sides.dat". Use the following data in "vertices.dat" (create your own text file): 4.0, 1.0 5.0, -2.2 1.1, -4.1 -3.1, -2.9 -5.1, -0.5 -4.2, 2.0 -2.1, 3.3 1.5, 3.8 Question 2 (25%) In analytical geometry, a convex polygon can be represented by the Cartesian coordinates x and y of its vertices. Assume such data of a polygon are stored in a file called vertices.dat. Each line of the file contains a pair of real numbers (separated by a comma) describing the coordinates of n points (one pair per line). Create a VB Console Application called Polygon according to the following instructions: 1. In Sub Main, declare all necessary variables including an array with the x coordinates of the points, and an array with the y coordinates of the points, etc. Assume static array sizes of Nmax = 20, i.e., allow a maximum of 20 points. The program should stop with an appropriate message if the user supplies a file with more than Nmax data points. The main program should call all Subs and Functions discussed in points 2 to 5 below. Do not use UDTS! 2. Write a Sub Open_File which opens the input file vertices.dat" and reads the coordinates of the points from the input file. 3. Write a Sub Calc_Length which calculates the length of all sides of the polygon. 4. Write a Function Perimeter which calculates the perimeter of the polygon. 5. Write a Sub Output_File which writes the length of all sides and the perimeter into an output file called "sides.dat". Use the following data in "vertices.dat" (create your own text file): 4.0, 1.0 5.0, -2.2 1.1, -4.1 -3.1, -2.9 -5.1, -0.5 -4.2, 2.0 -2.1, 3.3 1.5, 3.8

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 Accounting Questions!