Calculate Rectangle Perimeter using it's length and width.

 


public class Main {
  public static void main(String[] args) {
    int width = 10;
    int length = 5;

    int perimeter = 2 * (length + width);
    System.out.println("Perimeter of a rectangle is " + perimeter);
  }
}

 

The output:


Perimeter of a rectangle is 30
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.