Guest User

Untitled

a guest
Oct 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace PeerGradedAssignment1
  8. {
  9. /// <summary>
  10. /// For deciding the approach of point 1 to point 2
  11. /// </summary>
  12.  
  13. class Program
  14. { /// <summary>
  15. /// Taking values of points
  16. /// </summary>
  17. /// <param name="args">Command-line args</param>
  18. static void Main(string[] args)
  19. {
  20. // Asking for values(X,Y) of point1 and point
  21.  
  22. Console.Write("Welcome");
  23. Console.WriteLine(". In this aplication I will calculate" +
  24. "the distance between two pints and the amgle between them.");
  25. Console.WriteLine();
  26.  
  27. Console.Write("Enter the X value for the 1st point: ");
  28. float pointX1 = float.Parse(Console.ReadLine());
  29.  
  30. Console.Write("Enter the Y value for the 1st point: ");
  31. float pointY1 = float.Parse(Console.ReadLine());
  32.  
  33. Console.WriteLine();
  34.  
  35. Console.Write("Enter the X value for the 2nd point: ");
  36. float pointX2 = float.Parse(Console.ReadLine());
  37.  
  38. Console.Write("Enter the Y value for the 2nd point: ");
  39. float pointY2 = float.Parse(Console.ReadLine());
  40.  
  41. // Claculating the distance between point1 and point2
  42.  
  43. float deltaX = pointX2 - pointX1;
  44. float deltaY = pointY2 - pointY1;
  45. // dist12 , 12 stands for 1-2
  46. float squaredist12 = deltaX * deltaX + deltaY * deltaY;
  47. float dist12 = (float)Math.Sqrt(squaredist12);
  48. Console.WriteLine("Distance between point and point 2:" + " " + dist12);
  49.  
  50. // Calculating the angle between them
  51.  
  52. float radians = (float)Math.Atan2(deltaX,deltaY);
  53.  
  54. // Converting radians to angles
  55.  
  56. float degrees = (float)radians * (180 / (float)Math.PI);
  57. Console.WriteLine(degrees);
  58. Console.WriteLine(dist12.ToString("D3"));
  59. }
  60. }
  61. }
  62.  
  63. Console.WriteLine(dist12.ToString("n3"));
Add Comment
Please, Sign In to add comment