title: C++ float questions
body: <p>I'm having a hard time with floats &amp; doubles concept.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  int main() {
  
      const float classA = 15.00f;
      const float classB = 12.00f;
      const float classC = 9.00f;
      int soldA,
      soldB,
      soldC;
      float total = 1.00f;
  
      std::cout &lt;&lt; "How many Class A tickets where sold? : ";
      std::cin &gt;&gt; soldA;
      std::cout &lt;&lt; "How many class B tickets were sold? : ";
      std::cin &gt;&gt; soldB;
      std::cout &lt;&lt; "How many Class C tickets were sold? : ";
      std::cin &gt;&gt; soldB;
  
      printf("%f\n", total = (classA * soldA) + (classB * soldB) + (classC * soldC));
  
      std::cout &lt;&lt;"The total amount collected : $" &lt;&lt; total &lt;&lt; endl;
  }
  </code></pre>
  
  <p>At the last line, I want to print total to be the float in precision of 2 (like dollars), but in the printf works fine when I compile it, but it loses the precision at the last line.</p>
  
  <p>How do I fix this? Or show the precision?</p>