# Answer to Question #33518 in Java | JSP | JSF for Jimbo

Question #33518
Write a class Square whose constructor receives the height of the sides. Then supply methods to compute -the area and parameter of the square -the length of the diagonal (use the Pythagorean theorem)
import java.util.*;
import java.lang.*;

class Square {
double height;
public Square(double Hscan) {
height = Hscan;}
public double area(double H) {return H*H;}
public double perimeter(double H) {return 4*H;}
public double diagonal(double H) {return H*Math.sqrt(2);}
public static void main (String[] args) {
System.out.println(&quot;Enter the height of a square:&quot;);
System.out.print(&quot;the height = &quot;);
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
double h = Double.parseDouble(s);
Square sq = new Square(h);
System.out.println(&quot;An area of the square = &quot;+sq.area(h)+&quot; with the height = &quot;+h);
System.out.println(&quot;A perimeter of the square = &quot;+sq.perimeter(h)+&quot; with the height = &quot;+h);
System.out.println(&quot;A lenght of the diagonal of the square = &quot;+sq.diagonal(h)+&quot; with the height = &quot;+h);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!