logo image

Java program to calculate parallelogram circumference



Following program shows you how to calculate parallelogram circumference. This program gets parallelogram base and side from user and calculates circumference and prints it using following formula Circumference = 2 X base X side

import java.util.Scanner;

public class MathGeometry7 {

	public static void main(String[] args) {

		double parallelogramBase;
		double parallelogramSide;

		Scanner in = new Scanner(System.in);

		System.out.println("Please enter base of parallelogram: ");
		parallelogramBase = in.nextInt();

		System.out.println("Please enter side of parallelogram: ");
		parallelogramSide = in.nextInt();

		double circumferenceOfParallelogram = 2 * (parallelogramBase + parallelogramSide);
		System.out.println("Circumference of parallelogram is: " + circumferenceOfParallelogram);

	}
}

Output:

Please enter base of parallelogram: 
10
Please enter side of parallelogram: 
30
Circumference of parallelogram is: 80.0