Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Peace Love Auditing Journal

Authors: Epic Love Books

1st Edition

1697161693, 978-1697161694

More Books

Students also viewed these Accounting questions