Re: need help soon on error.
First problem is in the sqArea function. You pass it a SquareObject argument, but it looks as if the argument should be a Square ... and not the Square class itself but an instance of the Square class ... i.e.
Code:
/**
* This method receives a Square object as a parameter.
*/
public static int sqArea(Square s) {
int area;
area = s.len * s.len;
return area;
} // end of sqArea method
Line 9
Code:
SquareObject Square = new SquareObject();
A variable named "Square" of type SquareObject is never used, plus it could be confusing whether Square is an instance of SquareObject or the class Square defined later on. Get rid of this line.
Line 13
Code:
s = getSquare();
area = sqArea(Square);
You need to be passing an instance of Square to the sqArea function, not the type itself ... i.e.
Code:
s = getSquare();
area = sqArea(s);
In the getSquare method,
Code:
s UserSquare; // declare an object reference variable of type Square
is trying to create a variable names UserSquare of type s ... s is not defined. That is what the compiler is telling you.
You probably want a variable named userSquare (note the lower case u ... good convention). Then when you construct it having got the side length, create a new Square(sideLen) not a new s(sideLen). i.e.
Code:
sideLen = scan.nextInt(); // get the user's entry
userSquare = new Square(sideLen);
Finally, the getSquare function needs to return an instance of the Square class - the one that has just been initialised.