Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Task1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. RightTriangle rightTriangle = new RightTriangle();
  13.  
  14. Console.WriteLine("Area of Right Triangle is " + rightTriangle.GetArea() + "units");
  15.  
  16. Console.WriteLine();
  17.  
  18. Rectangle rectangle = new Rectangle();
  19.  
  20. Console.WriteLine("Area of Right Triangle is " + rectangle.GetArea() + "units");
  21. }
  22. }
  23.  
  24. abstract class Shape
  25. {
  26. public double x, y;
  27.  
  28. abstract public double GetArea();
  29. }
  30. class RightTriangle : Shape
  31. {
  32. public override double GetArea()
  33. {
  34. double area;
  35.  
  36. Console.WriteLine("Right Triangle\n");
  37.  
  38. Console.Write("Value of Base : ");
  39. x = Convert.ToDouble(Console.ReadLine());
  40.  
  41. Console.Write("Value of Perpendicular : ");
  42. y = Convert.ToDouble(Console.ReadLine());
  43.  
  44. area = 0.5 * x * y;
  45.  
  46. return area;
  47. }
  48. }
  49. class Rectangle : Shape
  50. {
  51. public override double GetArea()
  52. {
  53. double area;
  54.  
  55. Console.WriteLine("Reactangle\n");
  56.  
  57. Console.Write("Value of Base : ");
  58. x = Convert.ToDouble(Console.ReadLine());
  59.  
  60. Console.Write("Value of Perpendicular : ");
  61. y = Convert.ToDouble(Console.ReadLine());
  62.  
  63. area = 0.5 * x * y;
  64.  
  65. return area;
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement