bluej Programs
5.Write a program to enter the perimeter of a rectangle,which is equal to the perimeter of a square.Find out the area of the square.
import java.util.*;
class square_rect
{
void main()
{
Scanner sc=new Scanner(System.in);
int p,s,a;
System.out.println("Enter the perimeter of the rectangle:");
p=sc.nextInt();
s=p/4;
a=s*s;
System.out.println("Side of the Square:"+s);
System.out.println("Area of the Square:"+a);
}
}
Output:
Enter the perimeter of the rectangle: 64 Side of the Square:16 Area of the Square:256
ADVERTISEMENT
