Programming Examples
Java program to input the area of a square and find its perimeter
Write a program to input the area of a square and find its perimeter.
Solution
import java.util.*;
class Perimeter
{
public static void main(int n)
{
Scanner sc=new Scanner(System.in);
double a,s,p;
System.out.println(“Enter the area of a square:”);
a=sc.nextDouble();
s=Math.sqrt(a);
p=4*s;
System.out.println(“Perimeter=”+p);
}
}
Output