Advertisement
JOHNYTHEWINNER

Point in a circle

Apr 12th, 2015
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2.                    
  3. public class PointInACircle
  4. {
  5.     public static void Main()
  6.     {
  7.         Console.Write("Please input coordinates for x. x ="); // Here we ask for x coordinates
  8.         double x = double.Parse(Console.ReadLine());
  9.         Console.Write("Please input coordinates for y. y ="); // Here we ask for y coordinates
  10.         double y = double.Parse(Console.ReadLine());
  11.         Console.Write("Please input radius R. R =");// Here we ask for radius
  12.         double R = double.Parse(Console.ReadLine());
  13.  
  14.         bool isInside = (x * x) + (y * y) <= (R*R);  //Here we check is this point in the circle. If circle radius is different than 0,0 you should use (x-value of center ) and (y-value of center)
  15.  
  16.         Console.WriteLine("Are these coordinates in the circle? This is " + isInside + "!");  //Finally print it
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement