Computer Science, asked by 7004924737, 1 year ago

write a program in Java to find area,perimeter and diagonal of square

Answers

Answered by QGP
30
Hey There!!


Here's your code:


import java.util.Scanner;
public class Square
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
       
        System.out.print("Enter length of side of square: ");
        double l = sc.nextDouble();
       
        System.out.println("\nArea of square = "+(l*l));
        System.out.println("Perimeter of square = "+(4*l));
        System.out.println("Length of Diagonal of square = "+(l*Math.sqrt(2)));
    }
}



Hope it helps
Purva
Brainly Community

Answered by indranisen1312
12

import java.util.Scanner;

public class Square

{

    public static void main(String[] args)

    {

        Scanner sc = new Scanner(System.in);

       

        System.out.print("Enter length of side of square: ");

        double l = sc.nextDouble();

       

        System.out.println("\nArea of square = "+(l*l));

        System.out.println("Perimeter of square = "+(4*l));

        System.out.println("Length of Diagonal of square = "+(l*Math.sqrt(2)));

    }

}


Similar questions