CodesJava

Easy learning with example program codes

Calculate Rectangle Perimeter using Java Example

 
Perimeter of a rectangle = 2 * (length + width).

Program to Calculate Rectangle Perimeter using Java.

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

Output:

Rectangle Perimeter: 100

 

Please follow and like us:
error
Posted in Java   








Copyright © 2019 CodesJava DMCA.com Protection Status