UrbanPro
true

Learn C Sharp from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

C#-Program Rectangle and Circle

S
Salim Ahmed Ansari
18/01/2017 0 0

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//Namespace declaration
namespace figures
{
    //Rectangle Class declaration
    class rectangle
    {
        // member variables
        double length;
        double breadth;
        double height;
     
        //member function to accept data values
        public void Acceptdata()
        {
            length = 3.5;
            breadth = 2.5;
            height = 1.5;
  
        }
        //member function to get area and volume of rectangle
        public double GetArea_Rect()
        {
            return length * breadth;
        }
        public double GetVolume_Rect()
        {
            return length * breadth * height;
        }
       

        //member function to display dimensions of rectangle
        public void Dimension_Rect()
        {
            Console.WriteLine("Dimensions of rectangle");
            Console.WriteLine("Length: {0}", length);
            Console.WriteLine("Breadth: {0}", breadth);
            Console.WriteLine("Height: {0}\n", height);
        }
       
        //member function to display area of rectangle
        public void Display_Area()
        {
            Console.WriteLine("Area Of Rectangle: {0}", GetArea_Rect());
        }
        //member function to display volume of rectangle
        public void Display_Volume()
        {
            Console.WriteLine("Volume Of Rectangle: {0}\n", GetVolume_Rect());
        }
    }

        //Circle Class declaration
        class circle
        {
            // member variables
            double radius;
            //member function to accept data values
            public void Acceptdata()
            {
                radius = 5.5;
            }
            //member function to get area and circumference of circle
            public double GetArea_Circle()
            {
                return 3.14 * radius * radius;
            }
            public double GetCircumference()
            {
                return 2 * 3.14 * radius;
            }
            //member function to display dimensions of Circle
            public void Dimension_Circle()
            {
                Console.WriteLine("Dimensions of Circle");
                Console.WriteLine("Radius: {0}\n", radius);

            }
            //member function to display area of circle
            public void Display_Area()
            {
                Console.WriteLine("Area Of Circumference: {0}", GetArea_Circle());
            }
            //member function to display circumference of circle
            public void Display_Circumference()
            {
                Console.WriteLine("Circumference Of Circle: {0}\n", GetCircumference());
            }
       
    }
    //Main class declaration
    class ExecuteFigures
    {
        //Main method   
        static void Main(string[] args)
        {
            Console.WriteLine("**Geometric Figures**\n");

            // Creating instance/object of claas rectangle
            rectangle r = new rectangle();

            //Calling member functions using instance of class rectangle
            r.Acceptdata();
            r.Dimension_Rect();
            r.Display_Area();
            r.Display_Volume();

            // Creating instance/object of claas circle
            circle c = new circle();

            //Calling member functions using instance of class circle
            c.Acceptdata();
            c.Dimension_Circle();
            c.Display_Area();
            c.Display_Circumference();
           
        }
    }
}

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Extension Methods in C#
Extension methods enables you to add methods to existing types without creating a new derived type, recompiling or otherwise modifying the original type. Extension methods are special type of static methods,...

"foreach" loop in C#
foreach is a looping statement : repeats a group of statements for each element in an array or an object collection. (or) used to iterate through the collection/ an array to get the required information. Advantages: Easy...

Tips of learning Java Language/Other Programming Languages
1.You should know the basic concept: If we talk about programming languages so basic concept are same in all the high level languages. So you should know the basic concept firstly then you can easily understand...
I

ICreative Solution

0 0
0

Why a function in C# requires "Return type"??
- Basically , a Method is a piece of code used for the re-usability purpose. - Method is of 2 types Function and Procedure - Function is a method which returns a value to the calling place Function...

Read CSV data using ODBC Connection
Codes to read the CSV data using ODBC Connection- Input File: File's Encoding format should be ANSI as below class Student{ public string CollegeId { get; set; } public string AdmissionDate...

Looking for C Sharp Classes?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Sharp Classes?

The best tutors for C Sharp Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Sharp with the Best Tutors

The best Tutors for C Sharp Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more