title: How to convert 2 restricted decimal variables to a third variable and vice versa?
body: <p>I have 2 convertor methods as below:</p>
  
  <pre><code>private const decimal MaxValidValue = 99.99m;
  public decimal ConvertABToC(decimal a, decimal b)
  {
      return a * b;
  }
  
  public void ConvertCtoAB(decimal c, ref decimal a, ref decimal b)
  {
      if (c &gt; MaxValidValue*MaxValidValue)
      {
          throw new ApplicationException();
      }
  
      if (c &lt;= MaxValidValue)
      {
          a = 1.00m;
          b = c;
      }
      else 
      {
          // need to introduce some logic or assumptions here
      }
  }
  </code></pre>
  
  <p>There are 3 important things to know:</p>
  
  <p>1) The a and b variables are in the range of 0.00 to 99.99 therefore c can't have a value greater than 99.99*99.99</p>
  
  <p>2) the a, b and c must not have more than 2 decimal precession e.g. a = 99.123 would be invalid.</p>
  
  <p>3) you can use rounding if you'd need to as long as decimal.Round(a * b, 2) == c. </p>
  
  <p>4) combinations like (1, 3), (3, 1), (2, 2), (1, 4), (0.5, 8) or even (0.25, 16) are all valid; it doesn't matter as long as c would be the product of a and b. </p>
  
  <p>How would you complete the implementation of ConvertCtoAB?</p>
  
  <p>Many thanks,</p>