desislava777

AreaOfFigure

Sep 28th, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 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 ConsoleApplication62
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var figura = Console.ReadLine();
  14. double area;
  15. if (figura == "square")
  16. {
  17. var a = double.Parse(Console.ReadLine());
  18. area = a * a;
  19. Console.WriteLine(Math.Round(area, 3));
  20. }
  21. else if (figura == "rectangle")
  22. {
  23. var b = double.Parse(Console.ReadLine());
  24. var c = double.Parse(Console.ReadLine());
  25. area = b * c;
  26. Console.WriteLine(Math.Round(area, 3));
  27. }
  28. else if (figura == "circle")
  29. {
  30. var radius = double.Parse(Console.ReadLine());
  31. area = Math.PI * radius * radius;
  32. Console.WriteLine(Math.Round(area, 3));
  33. }
  34. else if (figura == "triangle")
  35. {
  36. var k = double.Parse(Console.ReadLine());
  37. var h = double.Parse(Console.ReadLine());
  38. area = (k * h) / 2.0;
  39. Console.WriteLine(Math.Round(area, 3));
  40. }
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment