pupesko

SoftUni - 5.10 Inside a Circle & Outside of a Rectangle

Oct 13th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. //Write an expression that checks for given point (x, y) if it is within the circle K({1, 1}, 1.5) and out of the rectangle R(top=1, left=-1, width=6, height=2).
  2.  
  3. using System;
  4.  
  5. class InsideOutside
  6. {
  7.     static void Main()
  8.     {
  9.         Console.Write("Enter x: ");
  10.         double x = double.Parse(Console.ReadLine());
  11.  
  12.         Console.Write("Enter y: ");
  13.         double y = double.Parse(Console.ReadLine());
  14.  
  15.         double circle = ((x - 1) * (x - 1)) + ((y - 1) * (y - 1));
  16.        
  17.         if ((circle <= 2.25) && ((x > 5) || (x < -1) && (y < -1) || (y > 1)))
  18.         {
  19.             Console.WriteLine("yes");
  20.         }
  21.         else
  22.         {
  23.             Console.WriteLine("no");
  24.         }
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment