Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- /*
- * 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)
- */
- class PointInsideCircleAndRectangle
- {
- static void Main()
- {
- double radious = 1.5 * 1.5;
- byte centerX = 1;
- byte centerY = 1;
- Console.Write("Please enter X and Y\n x = ");
- float coordinateX = float.Parse(Console.ReadLine());
- Console.Write(" y = ");
- float coordinateY = float.Parse(Console.ReadLine());
- float pointsCoordinates = (float)((coordinateX - centerX) * (coordinateX - centerX) + (coordinateY - centerY) * (coordinateY - centerY));
- bool inCircle = radious - pointsCoordinates >= 0;
- bool inRectangle = coordinateX >= -1 && coordinateX <= 5 && coordinateY >= -1 && coordinateY <= 1; // check if the point are in the rectangle
- if (inCircle && inRectangle)
- {
- Console.WriteLine("\nThe point wirh coordinates ( {0} : {1} ) is in the both figures!\n", coordinateX, coordinateY);
- }
- if (inCircle && !inRectangle)
- {
- Console.WriteLine("\nThe point wirh coordinates ( {0} : {1} ) is in the circle and out of the rectangle!\n", coordinateX, coordinateY);
- }
- if (!inCircle && inRectangle)
- {
- Console.WriteLine("\nThe point wirh coordinates ( {0} : {1} ) is in the rectangle and out of the cirlce!\n", coordinateX, coordinateY);
- }
- if (!inCircle && !inRectangle)
- {
- Console.WriteLine("\nThe point wirh coordinates ( {0} : {1} ) is outside both figures!\n", coordinateX, coordinateY);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement