Tuesday, 3 January 2017

C# and VB.net code for land area computation


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AREA
{
    class Program
    {
        static void Main(string[] args)
        {
           double  SUMA1=0;
           double  SUMA2 = 0;
           double innorth;
           double ineast;
            int n;
            Console.WriteLine("enter number of stations");
            n = int.Parse(Console.ReadLine());
            Console.WriteLine("enter initial Northing");
            innorth = double.Parse(Console.ReadLine());
            Console.WriteLine("enter initial Easting");
            ineast = double.Parse(Console.ReadLine ());
            for (int i = 1; i <= n; i++)
            {
                if (i == n) { Console.WriteLine("enter initial Northing"); }
                else
                {
                    Console.WriteLine("enter next Northing");
                }
                double n1 = double.Parse(Console.ReadLine());
                if (i == n) { Console.WriteLine("enter initial Easting"); }
                else
                {
                    Console.WriteLine("enter next Easting");
                }
                double e1 = double.Parse(Console.ReadLine());
                double A1 = innorth * e1;
                double A2 = ineast * n1;
                SUMA1 = SUMA1 + A1;
                SUMA2 = SUMA2 + A2;
                Console.WriteLine("A1= "+A1);
                Console.WriteLine("A2= "+A2);
                innorth =n1;
                ineast = e1;
            }
            Console.WriteLine("SUM(A1)= " + SUMA1);
            Console.WriteLine("SUM(A2)= " + SUMA2);
            double areaa = (Math.Abs(SUMA1 - SUMA2)) / 2;
            Console.WriteLine("AREA = "+areaa );
            Console.ReadKey();

        }
    }

}


Vb.net code  for land area computation
Module Module1

    Sub Main()
        Dim SUMA1 As Double
        SUMA1 = 0
        Dim SUMA2 As Double
        SUMA2 = 0
        Dim innorth As Double
        Dim ineast As Double
        Dim n As Integer
        Console.WriteLine("enter number of stations")
        n = Console.ReadLine()
        Console.WriteLine("enter initial Northing")
        innorth = Console.ReadLine()
        Console.WriteLine("enter initial Easting")
        ineast = Console.ReadLine()
        For i = 1 To n Step 1

            If i = n Then
                Console.WriteLine("enter initial Northing")
            Else
                Console.WriteLine("enter next Northing")
            End If
            Dim n1 As Double
            n1 = Console.ReadLine()
            If i = n Then
                Console.WriteLine("enter initial Easting")
            Else
                Console.WriteLine("enter next Easting")
            End If
            Dim e1, A1, A2 As Double
            e1 = Console.ReadLine()
            A1 = innorth * e1
            A2 = ineast * n1
            SUMA1 = SUMA1 + A1
            SUMA2 = SUMA2 + A2
            Console.WriteLine("A1= " & A1)
            Console.WriteLine("A2= " & A2)
            innorth = n1
            ineast = e1
        Next
        Console.WriteLine("SUM(A1)= " & SUMA1)
        Console.WriteLine("SUM(A2)= " & SUMA2)
        Dim areaa As Double
        areaa = (Math.Abs(SUMA1 - SUMA2)) / 2
        Console.WriteLine("AREA = " & areaa)
        Console.ReadKey()
    End Sub

End Module


To download Area.exe click here

No comments:

Post a Comment

History of Land Surveying

The yesteryear of plot surveying is as a matter of fact interesting and march to a different drummer and it is in fact a well-known...