Question: I want to create a program in Java, which -- basing on user inputs -- finds the area of the entered shape. But I failed to achieve that.

This is my script:

```
import java.util.Scanner;

public class area {
static Scanner advance = new Scanner(System.in);
public  void main(String[] args) {

    nu();
}
int length;
    int height;
int area;

public  void nu(){
    String message = advance.nextLine();

    if (message.equalsIgnoreCase("rectangle")){

        System.out.println("Enter the length of the rectangle: ");

        length  = advance.nextInt();

        //length declared.//
        System.out.println("Enter the height of the rectangle");

        height = advance.nextInt();

        //Height has been declared.//

        area = length * height;

        System.out.print("The area is: " + area);
    }
}
}

```

First problem is, that this code is not running and so I don't know if its working. All the other things are fine. Can you tell me, what I'm doing wrong?

Answer: 
1. You need to add `static` to the `main method` of your program.
2. You won't be able to directly call the `nu()` method from the `main`, as it is `instance method` to call it you will need to create an object of your class.

```
public static void main(String[] args) {

    area a = new area();
    a.nu();
}

```
3. The other alternate is that you can make your `nu()` method to be static but then you will not be able to use `int length;int height;int area;` instance variables directly in your `static method nu()`. Then you will either need to make these variables to be static too or create an object of the class and then use these variables as per your need.
Because of Java program can't find the main method to run:
We need to add static keyword in 3 places according to your code.

Please try with below full source code:

```
import java.util.Scanner;

public class area {
    static Scanner advance = new Scanner(System.in);

    public  static void main(String[] args) { //1st change

        nu();
    }
    static int length; //2nd change
    static int height; //2nd change
    static int area; //2nd change

    public static  void nu(){ //3rd change
        String message = advance.nextLine();

        if (message.equalsIgnoreCase("rectangle")){

            System.out.println("Enter the length of the rectangle: ");

            length  = advance.nextInt();

            //length declared.//
            System.out.println("Enter the height of the rectangle");

            height = advance.nextInt();

            //Height has been declared.//

            area = length * height;

            System.out.print("The area is: " + area);
        }
    }
}

```