Advertisement
desislava777

Area of Figures

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