i need a program that will compute area of various geometrical figures - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

i need a program that will compute area of various geometrical figures

I was wishing if someone could write a program that will compute tha area of various figures. This will prompt the user to select a square,rectangle or a triangle. depending on the user selection. and also the prompt should request for the measures. the script will calculate and display the name and the area. the user will be permitted to enter values with decimal places.

square: A =side*side
rectangle A=lenght*width
triangle A=1/2base*height

Comments

  • DerwentdaleDerwentdale Posts: 10Member
    There is a nice algorith available to calculate the area of a polygon defined by an array of x,y coordinate pairs.
    It relies on the idea that the area formed by any pair of points (Xi,Yi) and (Xi+1, Yi+1) and the points projected onto the X-axis is a trapezium, with area = (Xi+1-Xi)*(Yi+Yi+1)/2.
    Some trapeziums will have a negative and some a positive area. If you add all the areas traversing clockwise, the total is the area of the polygon. Going anti-clock gives the negative area.


    Clive

  • kolibrotherskolibrothers Posts: 13Member
    : There is a nice algorith available to calculate the area of a polygon defined by an array of x,y coordinate pairs.
    : It relies on the idea that the area formed by any pair of points (Xi,Yi) and (Xi+1, Yi+1) and the points projected onto the X-axis is a trapezium, with area = (Xi+1-Xi)*(Yi+Yi+1)/2.
    : Some trapeziums will have a negative and some a positive area. If you add all the areas traversing clockwise, the total is the area of the polygon. Going anti-clock gives the negative area.
    :
    :
    : Clive
    :
    :

    So do you think you can help me out?
    Thanks
  • kolibrotherskolibrothers Posts: 13Member
    : : There is a nice algorith available to calculate the area of a polygon defined by an array of x,y coordinate pairs.
    : : It relies on the idea that the area formed by any pair of points (Xi,Yi) and (Xi+1, Yi+1) and the points projected onto the X-axis is a trapezium, with area = (Xi+1-Xi)*(Yi+Yi+1)/2.
    : : Some trapeziums will have a negative and some a positive area. If you add all the areas traversing clockwise, the total is the area of the polygon. Going anti-clock gives the negative area.
    : :
    : :
    : : Clive
    : :
    : :
    :
    : So do you think you can help me out?


    : Thanks

    Just some few code to help me complete the program. Please.
    :

  • DerwentdaleDerwentdale Posts: 10Member

    : : So do you think you can help me out?
    :

    I thought that I had!
    What you seem to be asking is for someone to do it all for you. But, even if willing, you would need to specify where the data (x,y) points are coming from, and what form they would be in. After that it is pretty simple- you just need a function with a loop to tot up the contribution from each pair.
    Out of any context, it is difficult (for me at least) to be much more specific.


    Clive

Sign In or Register to comment.