Advertisement
svephoto

Area of Figures

Nov 14th, 2019
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2.  
  3. namespace IfElse
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string inp = Console.ReadLine();
  10. double area = 0;
  11.  
  12. if (inp == "square")
  13. {
  14. double a = double.Parse(Console.ReadLine());
  15. area = a * a;
  16. }
  17.  
  18. else if (inp == "rectangle")
  19. {
  20. double w = double.Parse(Console.ReadLine());
  21. double h = double.Parse(Console.ReadLine());
  22. area = w * h;
  23. }
  24.  
  25. else if (inp == "circle")
  26. {
  27. double r = double.Parse(Console.ReadLine());
  28. area = Math.PI * r * r;
  29. }
  30.  
  31. else if (inp == "triangle")
  32. {
  33. double a = double.Parse(Console.ReadLine());
  34. double b = double.Parse(Console.ReadLine());
  35. area = a * b / 2;
  36. }
  37.  
  38. Console.WriteLine($"{area:F3}");
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement