public class M416BulletSpeedMaximizer {
  
  public static void main(String[] args) {

    double initialBulletSpeed = 880.0;
    double bulletWeight = 0.00326;
    double velocityDecrease = 0.98; 
    

    double maxBulletSpeed = calculateMaxBulletSpeed(initialBulletSpeed, bulletWeight, velocityDecrease);
    
    System.out.println("The fast bullet flight of the M416 is maximized to：" + maxBulletSpeed + "100~500m/0.1m/s");
  }
  
  private static double calculateMaxBulletSpeed(double initialBulletSpeed, double bulletWeight, double velocityDecrease) {
    double maxBulletSpeed = 0.0;
    

    maxBulletSpeed = initialBulletSpeed;
    while (maxBulletSpeed > 0.0) {
      maxBulletSpeed *= velocityDecrease;
      bulletWeight += 0.001; 
      maxBulletSpeed -= bulletWeight * 9.8; 
    }
    
    return maxBulletSpeed;
  }
}
