Java Program to Calculate the Area of Parallelogram

You are currently viewing Java Program to Calculate the Area of Parallelogram

Java program to calculate the area of Parallelogram

// Java program to calculate the 
// area of Parallelogram

import java.util.Scanner;

public class Main {
  static float calcuateAreaOfParallelogram(float base, float altitude) {
    float result = 0.0F;

    result = base * altitude;

    return result;
  }

  public static void main(String[] args) {
    Scanner SC = new Scanner(System.in);

    float base = 0;
    float altitude = 0;
    float area = 0;

    System.out.printf("Enter the value of base: ");
    base = SC.nextFloat();

    System.out.printf("Enter the value of altitude: ");
    altitude = SC.nextFloat();

    area = calcuateAreaOfParallelogram(base, altitude);

    System.out.printf("Area of Parallelogram is: %f\n", area);
  }
}

Output

Enter the value of base: 1.2
Enter the value of altitude: 3.5
Area of Parallelogram is: 4.200000

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply