HI

I have this question :

Suppose we have a Rectangle class that begins:

class Rectangle {

private Point upperLeft; // the upper left corner point
private double height; // the height of the rectangle
private double width; // the width of the rectangle
isSquare method

Write an isSquare method that returns true if the rectangle is a square (and false otherwise).


I have wrote this code but it doesnt work....

package assignement01;

import java.awt.Point;
import java.util.Scanner;

public class Assignement01 {

public static void main(String[] args) {
// TODO code application logic here


Scanner x = new Scanner(System.in);
System.out.print("Enter Rectangle height: ");
double height = x.nextDouble();
System.out.print("Enter Rectangle width: ");
double width = x.nextDouble();


class Rectangle {

private Point upperLeft; // the upper left corner point
private double height; // the height of the rectangle
private double width; // the width of the rectangle


public boolean isSquare() {
if (height == width){
boolean answer = true;
System.out.println(" The answer is" + answer);
}
else{
boolean answer = false;
System.out.println(" The answer is" + answer);


}
}
}
}
}