Sample code:
public static double timeToHit(double enemyBearing, double enemyDistance, double gunHeading, double bulletPower) { return normalRelativeAngleDiff(enemyBearing,gunHeading)/20+enemyDistance/(20 - 3 * bulletPower); }
The first part
normalRelativeAngleDiff(enemyBearing,gunHeading)/20calculates time needed to rotate the gun, and the second one
enemyDistance/(20 - 3 * bulletPower)computes bullet travel time.