Calculate Rectangle Area using Java Example

 
Area of a rectangle = length * width.

Program to Calculate Rectangle Area using Java.

/**
 * Program to Calculate Rectangle Area using Java Example.
 * @author W3spoint
 */
public class RectangleAreaExample {
	static void rectangleArea(int length, int width){
                 //Calculate Rectangle Area.
		 int area = length * width;
                 //Print Rectangle Area.
                 System.out.println("Rectangle area: " + area);
	}	
 
	public static void main(String args[]){ 
		//method call 
		rectangleArea(20, 30); 
	}
}

Output:

Rectangle area: 600

 

Content Protection by DMCA.com
Please Share