Let’s learn area of parallelogram in java.
area of parallelogram in java
A parallelogram is four sided geometrical shape with opposite sides parallel and opposite angles equal.
To calculate area of parallelogram formula is:
area = base x height
Let’s see java program.
import java.util.Scanner; public class AreaOfParallelogram { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Please enter base of parallelogram: "); double base = sc.nextDouble(); System.out.println("Please enter height of parallelogram: "); double height = sc.nextDouble(); double area = base * height; System.out.println("Area of parallelogram is: " + area); sc.close(); } }
Output:
Please enter base of parallelogram:
5
Please enter height of parallelogram:
14
Area of parallelogram is: 70.0
Also read – inheritance in java