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

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

C Program to print Block Letter and Small Case Alphabets using C
/* WAP to print Block Letter and Small Case Alpahbets using C*/ //Hint:use ascii code(value) to print #include#include void main(){ int i; clrscr(); //Block Letters Alphabets printf("Block Letters Alphabets\n");...

C Program-The Odd Loop Demo
/* WAP to print square value of the number entered by user using odd loop*/ //Header Files #include<stdio.h>#include<conio.h> //Main Function void main(){ char another='y'; int num,sq; //...

Working with C/C++ applications
Inorder to learn C and C++ programming languages one can work with various editors available.To name a few are the most popular one is turbo c++, DEV C++, Eclipse, NetBeans. Here are the screen shots...

C Program-Vowels and Consonants
/*WAP to print the character entered by user is a vowel or consonant*/ //Header files #include<stdio.h>#include<conio.h> //Main functionvoid main(){ char c; //Function for clearing screen...

// Use of Const Keyword in C Programming
#include #include void main() { float rad; const float pi=3.1412f; const char newline='\n'; float area_circle,circum_circle; clrscr(); printf("Enter radius of a circle:"); scanf("%f",&rad); area_circle=pi*rad*rad; printf("Area...

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