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

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz