Locked C # programming

  • Friday, September 21, 2012 5:00 PM
     
     
    I am just starting out in a C # programming class and I was wondering if I could get some help with figuring out how to write a code to calculate the perimeter and area of a rectangle. Any help would be appreciated. 

All Replies

  • Friday, September 21, 2012 5:08 PM
     
     Answered Has Code

    Hi,

    Below code is for Area of a Rectanlge

    class Program    {  

          static void Main(string[] args)      

      {            double dWidth, dHeight;     

           double dArea;         

       Console.WriteLine("Enter the both side of rectangle (Height and Width):");    

            dHeight = Convert.ToDouble(Console.ReadLine());   

             dWidth = Convert.ToDouble(Console.ReadLine());        

        dArea = dHeight * dWidth;    

            Console.WriteLine("The area of rectangle is: " + dArea); 

               Console.ReadLine();      

      }    

    }




    PS.Shakeer Hussain

  • Friday, September 21, 2012 5:10 PM
     
     Answered

    It looks like homework, but i'll try to point you to the right direction.

    • Did you have values of each side form rectangle or user will type or even you will get it from database?

    If the user will type this values, it's simple, until the area is  A = width * height and perimeter is P = 2 * width + 2 * heigth.


    Web Developer

  • Friday, September 21, 2012 5:11 PM
     
     Answered

    Hi,

    Check the below link for calculating Perimeter in c#

    http://www.webber.edu/wunker/VisualC/RectangleCalc03Statements.htm


    PS.Shakeer Hussain

  • Friday, September 21, 2012 5:14 PM
     
     Answered Has Code

    Hi,

    Below code is for Area of a Rectanlge

    class Program    {  

          static void Main(string[] args)      

      {            double dWidth, dHeight;     

           double dArea;         

       Console.WriteLine("Enter the both side of rectangle (Height and Width):");    

            dHeight = Convert.ToDouble(Console.ReadLine());   

             dWidth = Convert.ToDouble(Console.ReadLine());        

        dArea = dHeight * dWidth;    

            Console.WriteLine("The area of rectangle is: " + dArea); 

               Console.ReadLine();      

      }    

    }

    Next time, you can give some credits to the Original author , rs.

    http://www.csharphub.com/2011/01/find-rectangle-area-in-c.html


    Web Developer

    • Marked As Answer by angelkisses1926 Tuesday, September 25, 2012 10:17 PM
    •  
  • Saturday, September 22, 2012 4:01 AM
     
     

    Never heard of comments :P


    Digital Forensic Software Developer
    CCS LABS Digital Forensic Software
    Mark as Answer or Vote up if useful thank you!

  • Saturday, September 22, 2012 4:02 AM
     
     
    naughty - I totally agree

    Digital Forensic Software Developer
    CCS LABS Digital Forensic Software
    Mark as Answer or Vote up if useful thank you!