# Java Program to Find Area of Parallelogram

In the previous article we have discussed Java Program to Find Area and Perimeter of Pentagon

## Program to Find Area of Parallelogram

Before jumping into the program directly, let’s first see how we calculate area of parallelogram.

Formula of Area of Parallelogram: base*height

Where,

• base‘ represents the base of parallelogram.
• height‘ represents the height of parallelogram.
Example- Area of Parallelogram

base = 3
height = 4
Area of Parallelogram = base*height
=  3*4
= 12

Let’s see different ways to do it.

Access the Simple Java program for Interview examples with output from our page and impress your interviewer panel with your coding skills.

### Method-1: Java Program to Find Area of Parallelogram By using Static Value

In this method, the base and height of the parallelogram is already defined in the program. And the area is calculated according to the formula by using this base and height values.

So, let’s see the program to see how it actually works.

import java.util.Scanner;

public class Main
{

public static void main(String[] args)
{
//creating Scanner class object
Scanner sc=new Scanner(System.in);
//base and height of parallelogram delared
int base=4;
int height=5;
//calculating area of paralleologram
int area=base*height;
System.out.println("Area of the parallelogram : "+area);
}
}

Output:

Area of the parallelogram : 20

### Method-2: Java Program to Find Area of Parallelogram By Using User Input Value

In this method, the base and height of the parallelogram will be taken as user input. And the area is calculated according to the formula by using that base and height values which are inputted by the user.

So, let’s see the program to see how it actually works.

import java.util.Scanner;

public class Main
{

public static void main(String[] args)
{
//creating Scanner class object
Scanner sc=new Scanner(System.in);
//Enter base of parallelogram
System.out.println("Enter base : ");
int base=sc.nextInt();
System.out.println("Enter height : ");
int height=sc.nextInt();
int area=base*height;
System.out.println("Area of the parallelogram : "+area);
}
}

Output:

Enter base : 4
Enter height : 5
Area of the parallelogram : 20

Guys who are serious about learning the concepts of the java programming language should practice this list of programs in java and get a good grip on it for better results in exams or interviews.

Related Java Programs: