Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- /*
- * Write an expression that checks if given point (x, y) is inside a circle K({0, 0}, 2).
- */
- class PointInACircle
- {
- static void Main()
- {
- int circleRad = 2, centerX = 0, centerY = 0;
- float pointX = 0, pointY = 0;
- bool isInCircle;
- Console.WriteLine("Provide point X coordinate:");
- while (!float.TryParse(Console.ReadLine(), out pointX))
- {
- Console.WriteLine("Please, enter valid integer.");
- }
- Console.WriteLine("Provide point Y coordinate:");
- while (!float.TryParse(Console.ReadLine(), out pointY))
- {
- Console.WriteLine("Please, enter valid integer.");
- }
- isInCircle = (Math.Pow((pointX - centerX),2)+Math.Pow((pointY - centerY),2)) <= Math.Pow(circleRad,2);
- Console.WriteLine("\nProvided point with coords ({0};{1}) is {2}", pointX, pointY,isInCircle?"inside the circle." : "outside the circle.\n");
- Console.WriteLine("Press any key to exit.");
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement