java program to find perimeter of a rectangle

Solutions on MaxInterview for java program to find perimeter of a rectangle by the best coders in the world

showing results for - "java program to find perimeter of a rectangle"
Clary
27 Nov 2016
1import java.util.Scanner;
2public class PerimeterOfRectangleDemo
3{    
4   public static void main(String []args)
5   {
6      float length, width, perimeter;
7      Scanner sc = new Scanner(System.in);
8      System.out.print("Please enter length of rectangle: ");
9      length = sc.nextFloat();
10      System.out.print("Please enter width of rectangle: ");
11      width  = sc.nextFloat();
12      perimeter = 2 * (length + width);
13      System.out.println("Perimeter of rectangle: " + perimeter);
14      sc.close();
15   }          
16}