Calculate Area for Rectangle, Square, Triangle, Circle in C#

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. namespace ConsoleApplication1  
  7. {  
  8.     class CalcAvgPerc //Calculate the Average marks and percentage for students  
  9.     {  
  10.         public float length, breadth, radius, side, hieght, breadthfortriangle;  
  11.         static void Main(string[] args)  
  12.         {  
  13.             CalcAvgPerc a = new CalcAvgPerc();  
  14.             a.Rectangle();  
  15.             a.Circle();  
  16.             a.Square();  
  17.             a.Triangle();  
  18.             Console.ReadKey();  
  19.         }  
  20.         public void Rectangle()  
  21.         {  
  22.             Console.WriteLine("Enter the Length for Rectangle");  
  23.             length = float.Parse(Console.ReadLine());  
  24.             Console.WriteLine("Enter the breadth for Rectangle");  
  25.             breadth = float.Parse(Console.ReadLine());  
  26.             System.Threading.Thread.Sleep(2000);  
  27.             Console.WriteLine("Area of rectangle is :{0}", length * breadth);  
  28.         }  
  29.         public void Circle()  
  30.         {  
  31.             Console.WriteLine("Enter the Radius of the Circle");  
  32.             radius = float.Parse(Console.ReadLine());  
  33.             System.Threading.Thread.Sleep(2000);  
  34.             Console.WriteLine("Area of Circle is:{0}", 3.14 * radius * radius);  
  35.         }  
  36.         public void Square()  
  37.         {  
  38.             Console.WriteLine("Enter the side of a square");  
  39.             side = float.Parse(Console.ReadLine());  
  40.             System.Threading.Thread.Sleep(2000);  
  41.             Console.WriteLine("Area of Square is:{0}", side * side);  
  42.         }  
  43.         public void Triangle()  
  44.         {  
  45.             Console.WriteLine("Enter the Breadth for Triangle ");  
  46.             breadthfortriangle = float.Parse(Console.ReadLine());  
  47.             Console.WriteLine("Enter the Hieght for Triangle ");  
  48.             hieght = float.Parse(Console.ReadLine());  
  49.             System.Threading.Thread.Sleep(2000);  
  50.             Console.WriteLine("Area of Triangle is:{0}", (breadthfortriangle * hieght) / 2);  
  51.         }  
  52.     }