Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class PointInsideCircleOutsideRectangle
- {
- static void Main()
- {
- Console.WriteLine("Point Inside a Circle & Outside a Rectangle");
- bool check;
- Console.WriteLine("\n" + "Please, set a position (xo, yo) of the circle K, as follow:");
- Console.Write("\n" + "Horzontal coordinate \"xo\": ");
- double xo = double.Parse(Console.ReadLine());
- Console.Write("Vertical coordinate \"yo\": ");
- double yo = double.Parse(Console.ReadLine());
- Console.Write("\n" + "Please, enter the circle radius: ");
- double R = double.Parse(Console.ReadLine());
- Console.WriteLine("\n" + "Please, determine the borders of the rectangle R, as follow:");
- Console.Write("\n" + "Left vertical border \"xMin\": ");
- double xMin = double.Parse(Console.ReadLine());
- Console.Write("Right vertical border \"xMax\": ");
- double xMax = double.Parse(Console.ReadLine());
- double width = xMax - xMin;
- Console.Write("\n" + "Lower horizontal border \"yMin\": ");
- double yMin = double.Parse(Console.ReadLine());
- Console.Write("Upper horizontal border \"yMax\": ");
- double yMax = double.Parse(Console.ReadLine());
- double height = yMax - yMin;
- Console.Write("\n" + "Please, enter \"x\" coordinate of a point: ");
- double x = double.Parse(Console.ReadLine());
- Console.Write("Please, enter \"y\" coordinate of a point: ");
- double y = double.Parse(Console.ReadLine());
- if ( Math.Pow(x-xo, 2) + Math.Pow(y-yo, 2) <= Math.Pow(R, 2) && ((x >= xMin || x <= xMax) && (y >= yMin || y <= yMax)) )
- {
- check = true;
- Console.WriteLine("\n" + "Is the point with coordinates ({0};{1}) within the circle K(({2};{3}) {4}) and" + "\n"
- + "out of the rectangle R(top={5}, left={6}, width={7}, height={8}): {9}", x, y, xo, yo, R, yMax, xMin, width, height, check);
- }
- else
- {
- check = false;
- Console.WriteLine("\n" + "Is the point with coordinates ({0};{1}) within the circle K(({2};{3}) {4}) and" + "\n"
- + "out of the rectangle R(top={5}, left={6}, width={7}, height={8}): {9}", x, y, xo, yo, R, yMax, xMin, width, height, check);
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment