Saturday, 26 December 2020

Write a Program in Java to find out the Diagonal of a Square taking side of a Square as Input.

import java.util.*;

class Diagonal

{

    public static void main(String args[])

    {

        Scanner in=new Scanner(System.in);

        double a,d;

        System.out.println("Enter the side of the Square");

        a=in.nextInt();

        d=Math.sqrt(2)*a;

        System.out.println("Side of the Square= "+a);

        System.out.println("Diagonal of the Square= "+d);

    }

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...