Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Create a class named Square that contains only two data fields that contain th

ID: 3635325 • Letter: 1

Question

1.Create a class named Square that contains only two data fields that contain the height and width . You must declare these fields as ‘private’.
2.The constructor should take parameters to initialize height and width.
3.Write a method named computeSurfaceArea() that calculates and returns the surface area of the square based on the height and width fields.
4.Save this class as Square.java

I'm missing something in this program?

public class square

{
private double height;
private double width;
public square()
{
}
public square(double h,double w){
height=h;
width=w;
}

public double SurfaceArea(){
return height*width;
}

}

Explanation / Answer

You have placed }{ not correctly