A Program to Find the Area of a Parallelogram
In this example, we are giving a program to find the area of a parallelogram. The rule of finding the area of a parallelogram is: A = base * vertical_height.
Program to find the area of a parallelogram:
import java.util.Scanner; //Scanner class helps to get input from user
class triangle {
public static void main(String[] args) {
Scanner s = new Scanner(System.in); //Scanner class object declaration
System.out.println("Enter the base of parallelogram: ");
float b = s.nextFloat(); // takes float input base from keyboard or user or run time
System.out.println("Enter the height of parallelogram: ");
float h = s.nextFloat(); // takes float input height from keyboard or user or run time
float area = b * h;
System.out.println("Area of Parallelogram: "+ area);
}
}
Output:
Enter the base of parallelogram: 3 Enter the height of parallelogram: 4 Area of Parallelogram: 12.00