Java Program || Write a Java program to enter length and breadth of a rectangle and find its perimeter.
JAVA Program
Static
Write a Java program to enter length and breadth of a rectangle and find its perimeter.
class prectangle
{
public static void main(String args[])
{
int length=10,Width=5;
int perimeter = 2*(length + Width);
System.out.println("The perimeter of rectangle is :- "+perimeter);
}
}
Output :-
Dynamic
import java.util.*;
class prectangle
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the Length");
int len = in.nextInt();
System.out.println("Enter the Width");
int Width = in.nextInt();
int perimeter = 2*(len + Width);
System.out.println("The perimeter of a rectangle is :-" +perimeter);
}
}
Output :-