Trying to figure the math equation and the java at the same time