Advertisement
dimipan80

3.7 Point In A Circle

Jun 5th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. // Write an expression that checks if given point (x,  y) is inside a circle K({0, 0}, 2).
  2.  
  3. namespace _07.PointInACircle
  4. {
  5.     using System;
  6.  
  7.     public class PointInACircle
  8.     {
  9.         private const double Radius = 2d;
  10.  
  11.         public static void Main(string[] args)
  12.         {
  13.             checked
  14.             {
  15.                 Console.Write("Enter value of coordinate X of given point: ");
  16.                 double pointX = double.Parse(Console.ReadLine());
  17.                 Console.Write("Enter value of coordinate Y of given point: ");
  18.                 double pointY = double.Parse(Console.ReadLine());
  19.                 bool pointIsInTheCircle = true;
  20.                 double temp = Math.Sqrt((pointX * pointX) + (pointY * pointY));
  21.                 if (temp > Radius)
  22.                 {
  23.                     pointIsInTheCircle = false;
  24.                 }
  25.  
  26.                 Console.WriteLine("Given point is In the Circle: {0} !", pointIsInTheCircle);
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement