Computer Science, asked by tanishapaul1340, 7 months ago

help me out with this program .
And show the working by using "Scanner class". ​

Attachments:

Answers

Answered by BrainlyProgrammer
3

Answer:

Scanner sc=new Scanner (System.in) ;

int a=sc.nextInt() ; //enter side

double dia=0.0;

dia =Math.sqrt(2) *a;

System.out.println(a);

hope it helps u

Answered by anindyaadhikari13
2

Question:-

Write a java program to accept the diagonal of a square and display the area and perimeter of the square by using Scanner.

Code:-

import java.util.*;

class Square

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the diagonal: ");

double d=sc.nextDouble();

double a=d/Math.sqrt(2);

System.out.println("Area is: "+(a*a));

System.out.println("Perimeter is: "+(4*a));

}

}

Similar questions