Write a program that calculates and displays the area of a rectangle.

###### Solution

The area of a rectangle can be calculated using the following formula:

Area = Base × Height

In this exercise, the user enters values for Base and Height and the program (or script) calculates and displays the area of the rectangle. The solution to this problem is shown here.

## PHP

```<?php
echo "Enter the length of Base: ";
\$base_parallelogram = trim(fgets(STDIN));
echo "Enter the length of Height: ";
\$height_parallelogram = trim(fgets(STDIN));

\$area = \$base_parallelogram * \$height_parallelogram;

echo "The area of the parallelogram is ", \$area;
?>
```

## Java

```public static void main(String[] args) throws java.io.IOException {
double area, base_parallelogram, height_parallelogram;

System.out.print("Enter the length of Base: ");
System.out.print("Enter the length of Height: ");

area = base_parallelogram * height_parallelogram;

System.out.println("The area of the parallelogram is " + area);
}
```

## C++

```#include <iostream>
using namespace std;
int main() {
double area, base_parallelogram, height_parallelogram;

cout << "Enter the length of Base: ";
cin >> base_parallelogram;
cout << "Enter the length of Height: ";
cin >> height_parallelogram;

area = base_parallelogram * height_parallelogram;

cout << "The area of the parallelogram is " << area;
return 0;
}
```

## C#

```static void Main() {
double area, base_parallelogram, height_parallelogram;

Console.Write("Enter the length of Base: ");
Console.Write("Enter the length of Height: ");

area = base_parallelogram * height_parallelogram;

Console.Write("The area of the parallelogram is " + area);
}
```

## Visual Basic

```Sub Main()
Dim area, base_parallelogram, height_parallelogram As Double

Console.Write("Enter the length of Base: ")
Console.Write("Enter the length of Height: ")

area = base_parallelogram * height_parallelogram

Console.Write("The area of the parallelogram is " & area)

```base_parallelogram = float(input("Enter the length of Base: "))