title: Calculate weighted average with Java 8 streams
body: <p>How do I go about calculating weighted mean of a <code>Map&lt;Double, Integer&gt;</code> where the Integer value is the weight for the Double value to be averaged.
  eg: Map has following elements:</p>
  
  <ol>
  <li>(0.7, 100) // value is 0.7 and weight is 100</li>
  <li>(0.5, 200)</li>
  <li>(0.3, 300)</li>
  <li>(0.0, 400)</li>
  </ol>
  
  <p>I am looking to apply the following formula using Java 8 streams, but unsure how to calculate the numerator and denominator together and preserve it at the same time. How to use reduction here?</p>
  
  <p><a href="https://i.stack.imgur.com/YM946.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YM946.png" alt="enter image description here"></a></p>