Write a Java program to input the dimensions of a rectangle and find the area of
that square whose perimeter is equal to the perimeter of the rectangle.
Answers
Explanation:
public class Rectangle
{
public static void main( )
{
int b, l, ar, asq;
b = 4;
l = 8;
ar = 2( l+b );
asq = ar;
System.out.println (" The area of square =" + asq);
}
}
Question
Write a program to input the dimensions of a rectangle and find the area of that square whose perimeter is equal to the perimeter of the rectangle.
Solution:
import java.util.*;
public class Question
{
static void main()
{
Scanner sc=new Scanner(System.in);
float l,b,p,s,a;
System.out.println("Enter the length & breadth of the rectangle:");
l=sc.nextFloat();
b=sc.nextFloat();
p=2*(l+b); //perimeter of the rectangle
s=p/4; /*side of the square whose perimeter is equal
to the perimeter of the rectangle*/
a=s*s; //area of the square
System.out.println("Area of the Square:"+a);
}
}
Learn More on Brainly:
Write a program to print sum of Fibonacci series upto fifth term.
https://brainly.in/question/9009750
Write a program to input 5 integers and find the average.
https://brainly.in/question/29286707