An extension of the polygon area calculation by user input. There can be arbitrary many vertices of the polygon.1

We assume that the user only enters correct input strings.

Step 1

Read the number of vertices for the polygon from user input2.

Parse3 the input string to a number.

Only continue with the programm if the number is equal or greater than 3. If the input don’t match with that criteria, the user should enter a new number.

Step 2

Create the two arrays (empty) with the given count of vertices.

Step 3

Read the user input. The user input for a new vertex should be look like x-y. The input for the vertices end if both arrays are full.

Step 4

Split the string4 and use both coordinates separately.

Parse all the the input strings to numbers and save them in the array.

Step 5

Calculate the polygon area and print the soultion on the console.

  1. You can find the solution to this task Here.

  2. MSDN site for Console.WriteLine()

  3. MSDN site for int.Parse()

  4. MSDN site for String.Split()