title: Can't get the right answer while finding angle in C#
body: <p>I am doing this Introduction To Unity course from coursera. I have reached at first programming assignment which is to find the hypotenuse and angle of two points. I almost got the code right but a few answers are right and a few are wrong! I don't know what is wrong.</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ProgrammingAssignment1
  {
      // IMPORTANT: Only add code in the section
      // indicated below. The code I've provided
      // makes your solution work with the 
      // automated grader on Coursera
  
      /// &lt;summary&gt;
      /// Programming Assignment 1
      /// &lt;/summary&gt;
      class Program
      {
          // x and y coordinates for points
          static float point1X;
          static float point1Y;
          static float point2X;
          static float point2Y;
  
          /// &lt;summary&gt;
          /// Calculates angle and distance between two points
          /// &lt;/summary&gt;
          /// &lt;param name=&quot;args&quot;&gt;command-line args&lt;/param&gt;
          static void Main(string[] args)
          {
              // loop while there's more input
              string input = Console.ReadLine();
              while (input[0] != 'q')
              {
                  // extract point coordinates from string
                  GetInputValuesFromString(input);
  
                  // Add your code between this comment
                  // and the comment below. You can of
                  // course add more space between the
                  // comments as needed
                  
                  float deltaX = point1X - point2X;
                  float deltaY = point1Y - point2Y;
  
                  float hypotenuse = (float)Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2));
  
                  float angleInRadians = (float)Math.Atan2(deltaY, deltaX);
                  float angleInDegrees = angleInRadians * 180 / (float)Math.PI - 180;
              
  
                  Console.WriteLine(hypotenuse + &quot; &quot; + angleInDegrees);
  
                  // Don't add or modify any code below
                  // this comment
                  input = Console.ReadLine();
              }
          }
  
          /// &lt;summary&gt;
          /// Extracts point coordinates from the given input string
          /// &lt;/summary&gt;
          /// &lt;param name=&quot;input&quot;&gt;input string&lt;/param&gt;
          static void GetInputValuesFromString(string input)
          {
              // extract point 1 x
              int spaceIndex = input.IndexOf(' ');
              point1X = float.Parse(input.Substring(0, spaceIndex));
  
              // move along string and extract point 1 y
              input = input.Substring(spaceIndex + 1);
              spaceIndex = input.IndexOf(' ');
              point1Y = float.Parse(input.Substring(0, spaceIndex));
  
              // move along string and extract point 2 x
              input = input.Substring(spaceIndex + 1);
              spaceIndex = input.IndexOf(' ');
              point2X = float.Parse(input.Substring(0, spaceIndex));
  
              // point 2 y is the rest of the string
              input = input.Substring(spaceIndex + 1);
              point2Y = float.Parse(input);
  
              #region Unfortunately, Mono doesn't have a Split method!
              //string[] values = input.Split(' ');
              //point1X = float.Parse(values[0]);
              //point1Y = float.Parse(values[1]);
              //point2X = float.Parse(values[2]);
              //point2Y = float.Parse(values[3]);
              #endregion
  
          }
      }
  }
  
  </code></pre>
  <p>You can see the code I added after the Add Your Code comment, so I have succeeded in finding the hypotenuse correctly but angle is where I am going wrong!</p>
  <pre><code>float angleInRadians = (float)Math.Atan2(deltaY, deltaX);
  float angleInDegrees = angleInRadians * 180 / (float)Math.PI - 180;
  </code></pre>
  <p>These are the two lines to find the angles. So when I input points 5 5 4 4 it gives me correct angle with  Math.PI - 180 in the second line but at the same time when I input 2 2 4 4 it gives me wrong answer.</p>
  <p>So I played with it for a while and added Math.PI + 180, so this time I got the right angle for 2 2 4 4 and wrong answer for 5 5 4 4. I just don't know where I am going wrong!</p>
  <p>Some help would be highly appreciated!</p>