Advertisement
remote87

Point in a Circle

Aug 29th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Globalization;
  7.  
  8. namespace _07PointInACircle
  9. {
  10.     class PointInACircle
  11.     {
  12.         static void Main()
  13.         {
  14.             System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  15.             do
  16.             {
  17.                 Console.Write("Enter a value for x: ");
  18.                 float x = float.Parse(Console.ReadLine());
  19.                 Console.Write("Enter a value for y: ");
  20.                 float y = float.Parse(Console.ReadLine());
  21.                 float r = 2;
  22.                 if (((x * x) + (y * y)) == r * r)
  23.                 {
  24.                     Console.WriteLine("The point is on the circle.");
  25.                 }
  26.                 else if (((x * x) + (y * y)) < r * r)
  27.                 {
  28.                     Console.WriteLine("The point is inside the circle.");
  29.                 }
  30.                 else if (((x * x) + (y * y)) > r * r)
  31.                 {
  32.                     Console.WriteLine("The point is outside the circle.");
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine("Wrong coordinates.");
  37.                 }
  38.                 Console.Write("Do you want to continiue? (Y/N): ");
  39.                
  40.             } while (Console.ReadLine().ToUpper() == "Y");
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement