Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Task1
- {
- class Program
- {
- static void Main(string[] args)
- {
- RightTriangle rightTriangle = new RightTriangle();
- Console.WriteLine("Area of Right Triangle is " + rightTriangle.GetArea() + "units");
- Console.WriteLine();
- Rectangle rectangle = new Rectangle();
- Console.WriteLine("Area of Right Triangle is " + rectangle.GetArea() + "units");
- }
- }
- abstract class Shape
- {
- public double x, y;
- abstract public double GetArea();
- }
- class RightTriangle : Shape
- {
- public override double GetArea()
- {
- double area;
- Console.WriteLine("Right Triangle\n");
- Console.Write("Value of Base : ");
- x = Convert.ToDouble(Console.ReadLine());
- Console.Write("Value of Perpendicular : ");
- y = Convert.ToDouble(Console.ReadLine());
- area = 0.5 * x * y;
- return area;
- }
- }
- class Rectangle : Shape
- {
- public override double GetArea()
- {
- double area;
- Console.WriteLine("Reactangle\n");
- Console.Write("Value of Base : ");
- x = Convert.ToDouble(Console.ReadLine());
- Console.Write("Value of Perpendicular : ");
- y = Convert.ToDouble(Console.ReadLine());
- area = 0.5 * x * y;
- return area;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement