title: How to perform mathematical operations?
body: <p>I have been given the following assignment and am unsure how to implement it:</p>
  
  <blockquote>
    <p>Calculate the fee for a taxi ride. The formula is as follows:</p>
    
    <p>The first kilometer costs 50. Each extra 200m costs 5. If the distance
    is more than 30km then each extra kilometer adds 10 to the fee. The
    program has to input the total distance (in km) and calculate the
    charge.</p>
  </blockquote>
  
  <p>I wrote the following code but don't know what to do with "200m costs 5" part...</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  using namespace std;
  
  void main()
  {
      double totalfee, km, m;
      cout &lt;&lt; "distance" &lt;&lt; endl;
      cin &gt;&gt; km;
      m = km * 1000;
      if (km &lt; 30)
      {
          totalfee = 50;
          cout &lt;&lt; "totalfee = " &lt;&lt; totalfee &lt;&lt; endl;
      }
      else if (km &gt; 30)
      {
          totalfee = 60;
          cout &lt;&lt; "totalfee = " &lt;&lt; totalfee &lt;&lt; endl;
      }
      system("pause");
  }
  </code></pre>
  
  <blockquote>
    <p>it is in c++</p>
  </blockquote>