WAP to find the area and perimeter of a Rectangle.

import java.util.*; class T1 { public static void main(String[] args) { int a, l, w, p; Scanner sc = new Scanner(System.in); System.out.print("Enter the length of the rectangle: "); l = sc.nextInt(); System.out.print("Enter the width of the rectangle: "); w = sc.nextInt(); a = l * w; p = 2 * (l + w); System.out.println("Area of the rectangle: " + a); System.out.println("Perimeter of the rectangle: " + p); } } Copy Code
Expected Output:
Enter the length of the rectangle: 5
Enter the width of the rectangle: 3
Area of the rectangle: 15
Perimeter of the rectangle: 16