Miscellaneous
Java Program to Calculate Area of Rectangle
A Java program to calculate the Area of a Rectangle.
Problem Description
Write a Java program to calculate the Area of a Rectangle.
Code
public class AreaOfRectangle {
public static void main(String[] args) {
int width = 5;
int height = 10;
int area = width * height;
System.out.println("Area of rectangle=" + area);
}
}Output
Area of rectangle=50Explanation
- Formula:
width * height.
