Advertisement
adriyanbulgary

OperatorsExpressionsAndStatements - Task 7

Jun 13th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2. /*
  3. *Write an expression that checks if given point (x,  y) is inside a circle K({0, 0}, 2)
  4. */
  5. class PointInCircle
  6. {
  7.     static void Main()
  8.     {
  9.         float radious;
  10.         float pointX;
  11.         float pointY;
  12.         bool inCircle;
  13.         Console.WriteLine("What's circle's radious?");
  14.         radious = float.Parse(Console.ReadLine());
  15.         Console.WriteLine("Please enter value of X");
  16.         pointX = float.Parse(Console.ReadLine());
  17.         Console.WriteLine("Please enter value of Y");
  18.         pointY = float.Parse(Console.ReadLine());
  19.         inCircle = radious * radious - (pointX * pointX + pointY * pointY) > 0; //theorem of Pythagoras a^2 + b^2 =c^2
  20.         if (inCircle)
  21.         {
  22.             Console.WriteLine("The point is in the circle!");
  23.         }
  24.         else
  25.         {
  26.             Console.WriteLine("The point is outside the circle");
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement