ellapt

T11.4.TriangleSurface

Jan 25th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. class TriangleSurface
  4. {
  5. static void Main()
  6. {
  7. double aSide = 9.692;
  8. double ha = 5.382;
  9. double bSide = 8.39;
  10. double cSide = 6.29;
  11. double angle = 0.2217*Math.PI;
  12. double triangleSurface;
  13. Console.WriteLine("Calculate the surface of a triangle by given:\n");
  14. triangleSurface=(aSide*ha)/2;
  15. Console.WriteLine("Side and an altitude to it: \n\t\t(aSide*ha)/2 = \t{0:##.##}\n",triangleSurface);
  16.  
  17. double halfP = (aSide + bSide + cSide) / 2;
  18. triangleSurface=halfP*(halfP-aSide)*(halfP-bSide)*(halfP-cSide);
  19. triangleSurface = Math.Sqrt(triangleSurface);
  20. Console.WriteLine("Three sides: \nMath.Sqrt(p(p - a)(p - b)(p - c)) = {0:##.##} \n\twhere p = ½(a + b + c)\n", triangleSurface);
  21.  
  22. triangleSurface=(aSide*bSide*Math.Sin(angle))/2;
  23. Console.WriteLine("Two sides and an angle between them:\n (aSide*bSide*Math.Sin(angle))/2 = {0:##.##}\n", triangleSurface);
  24.  
  25.  
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment