Time needed to rotate the gun (Targeting) and bullet travel time.

Sample code:

public static double timeToHit(double enemyBearing, double enemyDistance, double gunHeading, double bulletPower) { return Math.abs(normalRelativeAngleDiff(enemyBearing,gunHeading))/20+enemyDistance/(20 - 3 * bulletPower); }

The first part

Math.abs(normalRelativeAngleDiff(enemyBearing,gunHeading))/20calculates time needed to rotate the gun, and the second one

enemyDistance/(20 - 3 * bulletPower)computes bullet travel time.