People your help would be appreciate very much. I just started working 15 hours a day and dont have alot of time for coding, so your help will be very much appreciate. below is the code i have now and i cant figure out what i have done wrong.
The error i am gett is below the code.............
Code:
import java.util.Scanner;
public class SquareObject {
// This is an example of how to return an object FROM a method
// and pass that same object TO another method
public static void main(String[] args) {
Square s; // declare an object reference variable of type Square
int area;
SquareObject Square = new SquareObject();
// Call a method, getSquare(), to create and return a new Square object
s = getSquare();
// Pass the new Square to a method to calculate the area
area = sqArea(Square);
System.out.println("The Area of the new Square is: " + area);
} // end of main method
// Other methods in the driver class
public static Square getSquare() {
// This method prompts the user for the size of a Square, and
// instantiates and returns a new Square object of that size
int sideLen;
s UserSquare; // declare an object reference variable of type Square
Scanner scan = new Scanner(System.in);
System.out.println("What size square do you want -- i.e. the length " +
"of each side? ") ;
sideLen = scan.nextInt(); // get the user's entry
userSquare = new s(sideLen); //found error on new usersquare //instantiate a Square of requested size
return ; // return the new object
} // end of getSquare method
public static int sqArea(SquareObject Square) {
// This method receives a Square object as a parameter
int area;
area = s.len * s.len;
return area;
} // end of sqArea method
} // end of the first (driver) class
class Square { // start of the Square (instance) class
int len;
// Constructor method - creates a square of a given size
public Square(int side) {
len = side;
System.out.println("Creating a square of size " + len);
}
} // end of Square class
I am fairly new to Java and i am a little confused on this
output: errors
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
s cannot be resolved to a type
userSquare cannot be resolved to a variable
s cannot be resolved to a type
This method must return a result of type Square
at SquareObject.getSquare(SquareObject.java:23)
at SquareObject.main(SquareObject.java:11)
Thank you all in advance for helping me