Write a program to input length and breadth of a rectangle and print its area and perimeter. (using java).
Answers
Answered by
1
Here I have used scanner class java
import java.util.Scanner;
public class Area Perimeter
{
public static void main(String[] args)
{
int l, b, perimeter, area;
Scanner in = new Scanner(System.in);
System.out.print("Enter length of rectangle:");
l = in.nextInt();
System.out.print("Enter breadth of rectangle:");
b = in.nextInt();
perimeter = 2 * (l + b);
System.out.println("Perimeter of rectangle:"+perimeter);
area = l * b;
System.out.println("Area of rectangle:"+area);
}
}
Similar questions