Advertisement
Guest User

Area of Figures

a guest
Apr 26th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 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 areaOfFigures
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string typeOfFigure = Console.ReadLine();
  14. double area = 0.0;
  15. switch (typeOfFigure)
  16. {
  17. case "Square":
  18. {
  19. double a = Double.Parse(Console.ReadLine());
  20. area = a * a;
  21. break;
  22. }
  23. case "Rectangle":
  24. {
  25. double a = Double.Parse(Console.ReadLine());
  26. double b = Double.Parse(Console.ReadLine());
  27. area = a * b;
  28. break;
  29. }
  30. case "Circle":
  31. {
  32. double radius = Double.Parse(Console.ReadLine());
  33. area = Math.PI * radius * radius;
  34. break;
  35. }
  36. case "Triangle":
  37. {
  38. double sideLenght = Double.Parse(Console.ReadLine());
  39. double hight = Double.Parse(Console.ReadLine());
  40. area = (sideLenght * hight) / 2;
  41. break;
  42. }
  43. }
  44. Console.WriteLine($"{area:f3}");
  45. }
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement