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;
- using System.Threading.Tasks;
- namespace ShapeProgram
- {
- class shape
- {
- public double width, hight, radius, axis;
- }
- class Circle : shape
- {
- public void CalculateCircle(double radius)
- {
- double Area = 22 / 7 * radius * radius;
- Console.WriteLine("Area = {0}", Area);
- }
- }
- class Square : shape
- {
- public void CalculateSquare(double axis)
- {
- double Area = axis * axis;
- Console.WriteLine("Area = {0}", Area);
- }
- }
- class Rectangle : shape
- {
- public void CalculateRectangle(double width, double hight)
- {
- double Area = (width + hight) * 2;
- Console.WriteLine("Area = {0}", Area);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Choose from\n1- Circle\n2- Square\n3- Rectangle\n");
- int n = int.Parse(Console.ReadLine());
- switch (n)
- {
- case 1:
- {
- Circle cr = new Circle();
- Console.Write("Enter Raduis of Circle : ");
- cr.radius = double.Parse(Console.ReadLine());
- cr.CalculateCircle(cr.radius);
- }
- break;
- case 2:
- {
- Square sq = new Square();
- sq.axis = double.Parse(Console.ReadLine());
- sq.CalculateSquare(sq.axis);
- }
- break;
- case 3:
- {
- Rectangle rec = new Rectangle();
- Console.Write("Enter Hight of Rectangle : ");
- rec.hight = double.Parse(Console.ReadLine());
- Console.Write("Enter Width of Rectangle : ");
- rec.width = double.Parse(Console.ReadLine());
- rec.CalculateRectangle(rec.hight, rec.width);
- }
- break;
- default:
- Console.WriteLine("error");
- break;
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement