Question: Do you see anything wrong in this code? in thosen't work well it returns a NaN.

```
public class Method2 extends GUIct1
{
double x=0,y=0;

void settype1 (double conv1)
{
x = conv1;
}

void settype2 (double conv2)
{
y = conv2;
}

double conversion ( double amount)
{

double converted = (amount*y)/x;
    return converted;
}

}

```

Way it is used an i already changed the set part

```
Method2 convert = new Method2(); \\ method is called

```

.....

```
convert.settype1(j);

```

.....

```
convert.settype2(k);

```

.....

```
double x = convert.conversion(i);
System.out.println(x);

```

Answer: 
Well, the fact that you've got methods which *set* variables called `get`-something is pretty obviously not a good idea, and there's no indentation... but it should *work*. But then, you haven't shown how you're using it. Perhaps you're not actually called the setter methods?

Here's an example of the same code but with different names, and a sample of using it:

```
class Converter
{
    double multiplier = 0;
    double divisor = 0;

    void setMultiplier(double multiplier)
    {
        this.multiplier = multiplier;
    }

    void setDivisor(double divisor)
    {
        this.divisor = divisor;
    }

    double convert(double amount)
    {
        return (amount * multiplier) / divisor;
    }
}

public class Test
{
    public static void main(String[] args)
    {
        Converter converter = new Converter();
        converter.setMultiplier(3.5);
        converter.setDivisor(8.5);
        System.out.println(converter.convert(2)); // Prints 0.8235294117647058
    }
}

```

Personally I'd probably make the variables final and set them in the constructor, but that's another matter...
This can happen when x=0. Division by zero is not defined. Print out x and y before you start to calculate to see whetther they are not zero.