title: Altering a structure variable with an "if" statement C++
body: <p>I have a homework assignment due tomorrow that wants us to prompt the user to enter in a number of cars, the miles driven on them, then display the total cost. The cost is dependent upon the amount of miles; if it's less than 100, it's 25 cents/miles and if it's more than 100 the cost is 100 + 15 cents/mile. I created a structure that holds <code>Miles</code> and <code>Price</code>. Here is what I have so far:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  struct Cars
  {
      int Miles;
      double Price;
  };
  
  int main()
  {    
      cout &lt;&lt; "ENTER ALL OF THE CARS!";
      int NoCars;
      cin &gt;&gt; NoCars;
      Cars* info = new Cars[NoCars];
      int i;
      for (i=0; i&lt;NoCars; i++)
      {
          cout &lt;&lt; "How many miles were driven on this car? :";
          cin &gt;&gt; info[i].Miles;
          if(Miles &gt; 100)
          {
              Price = 25 + 0.15 * Miles;
          } 
          else 
          {
              Price = 0.25*Miles;
          }
      }
      cout &lt;&lt; "Here are the prices: \n";
      for(x=0, x &lt; NoCars; x++)
      {
          cout &lt;&lt; info[x].Price;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>As you can see, I tried modifying the <code>Price</code> variable with an <code>if</code> statement, but it doesn't seem I can access it that simply. Any pointers?</p>