[Solved] Error using Math.pow and Math.sqrt in Java [closed]


v_y = 51 - time*3;
v = (int)Math.pow(v_y+20, 2);
v_squart = (int)Math.sqrt(v); // why take the square root of something you just squared...
height = 456 - v;
System.out.print("The height of the plane is" + height);

Integers cannot contain decimal values, Math.pow and Math.sqrt both return double types. You have declared v_y, v and v_squart as int types and you have to convert the operations to integers. You could also declare your variables as double types

int time;
double v_y;
double v;
double v_squart;
double height;

solved Error using Math.pow and Math.sqrt in Java [closed]