Computer Science, asked by fatimazehra25, 6 months ago

Write a program in java to compute and print the area and perimeter of a rectangle where length l

and breadth b will be entered by the user.​

Answers

Answered by anindyaadhikari13
1

Question:-

  • Write a program in java to compute and print the area and perimeter of a rectangle where length l and breadth b will be entered by the user.

Solution:-

In Java....

import java.util.*;

class Rectangle

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the length: ");

double l=sc.nextDouble();

System.out.print("Enter the breadth: ");

double b=sc.nextDouble();

double p=2*(l+b);

double a=l*b;

System.out.println("Perimeter is: "+p);

System.out.println("Area is: "+a);

}

}

Similar questions