Answer to Question #274337 in C# for Hilok

Question #274337

10. The coordinates of two points in the plane are known. Find their distance


Create a program.

1
Expert's answer
2021-12-02T00:38:11-0500
using System;
using System.Collections.Generic;


namespace App
{
    class Program
    {




        public static void Main()
        {
            double distance, x1, x2, y1, y2;


            Console.Write("Enter coordinate X for point A: ");
            x1 = Double.Parse(Console.ReadLine());
            Console.Write("Enter coordinate Y for point A: ");
            y1 = Double.Parse(Console.ReadLine());


            Console.Write("Enter coordinate X for point B: ");
            x2 = Double.Parse(Console.ReadLine());
            Console.Write("Enter coordinate Y for point B: ");
            y2 = Double.Parse(Console.ReadLine());


            distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));


            Console.WriteLine("Distance between points A and B: {0}", distance);


            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS