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
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
Math,
3 months ago
Math,
3 months ago
Social Sciences,
3 months ago
English,
6 months ago
Math,
6 months ago
Accountancy,
11 months ago
English,
11 months ago