Java Program to Calculate Area and Perimeter of Parallelogram

Hello coders, in this post, we will learn Java program to calculate area and perimeter of Parallelogram. In the previous tutorial, you have learned Java Program to calculate Area and Perimeter of Square.

We can calculate the parallelogram’s area and perimeter using the following formulas.

Area of Parallelogram= b×h

Perimeter of Parallelogram = 2(b+h)

Where,

  • b is base of the parallelogram.
  • h is height of the parallelogram.

Now let’s write the program.

Java Program to Calculate Area and Perimeter of Parallelogram

What we Did?

  • First of all we have imported the util package.
  • Then created a class and named it Parallelogram.
  • After that started main() method of the program.
  • Then inside main() method declared variables.
  • Then created object of the Scanner class.
  • Now asked the user to enter the height and breadth of the parallelogram. Then read the value of height and breadth of parallelogram entered by the user.
  • Then calculated area of parallelogram using the formula area = b * h
  • In the next line calculated perimeter of parallelogram using the formula perimeter = 2 * (b + h)
  • Then finally displayed the value of area and perimeter of parallelogram on the screen.

Output:

So in this tutorial, we learned how to write  Java program to calculate area and perimeter of Parallelogram. In the next tutorial, you will learn Java Program to calculate Area of Trapezium.


Related Tutorials…

Leave a Comment