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 userclass triangle {public static void main(String[] args) {Scanner s = new Scanner(System.in); //Scanner class object declarationSystem.out.println("Enter the base of parallelogram: ");float b = s.nextFloat(); // takes float input base from keyboard or user or run timeSystem.out.println("Enter the height of parallelogram: ");float h = s.nextFloat(); // takes float input height from keyboard or user or run timefloat 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