Money Problems ... double dose not work ..

Hi everyone

Iv done a bit of searching on this subject and i realize that their is a problem with financial calculations using doubles although iv read about bigdecimal and floating point but i am not sure how to implement them for my problem. Actually as I am relatively new to java (and maths) I am not even sure if I am going about this the right way but alas i will try to pick some of ye more experience guys brains.

The way I would describe this problem is

x*? = v*?

with x and v being fixed variables in a financial format e.g 4.50

and ? being the variable im looking for..

so 22.00*m = 10.00 + m

solve for m ..

I have tried rounding doubles to 2 decimal places which works (as im not extremely worried about accuracy) for smaller numbers but when i use larger numbers it dose not work

an example of this is

1.51*? = 10+ ?

returned

1.51*19.51 = 10*19.51 which is ok for my purposes.

I would like to make this work for lets say 54.20*? + 10+?

anyway here is my code so far (for what its worth)

Code:

`public class SimpleMain {`

public static void main(String[] args) {

for (double i =0.00; i< 100000.00; i =i +0.01) {

double m = 10.00;

double w = 3.03;

double x = roundTwoDecimals(i);

double z = roundTwoDecimals(w);

double v = roundTwoDecimals(m);

double q = z *x;

double p = roundTwoDecimals(q);

if( p == v + x ) {

System.out.println(x);

}

}

hope ye guys can help thanks