title: How to fix prompt for input C++ (Basic)
body: <p>I am trying to write a loop so that I prompt the user for input up to 4 times, the problem I have is that if the user inputs something other than the expected double value (for estimate) I need to output the message that this was not the correct type. I want to output this message and still prompt for and receive up to 4 more tries for estimate.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  
  int
  main ()
  {
  
   double estimate; 
   double increment;
   int numRows; 
  
   const int minRows = 1;
   const int maxRows = 100; 
   const double minInc = 0.1;
   const double maxInc = 10.0; 
   const double minEst = -10.0; 
   const double maxEst = 10.0; 
  
   string inputFile;
   int numTries = 0;
  
  
  
   while (numTries &lt; 4) 
  {
     numTries++;
     cout &lt;&lt; "Enter initial estimate of root : "; 
     cin &gt;&gt; estimate; 
  
     if (!(cin.fail())) 
     { 
       if ((estimate &gt;= minEst) &amp;&amp; (estimate &lt;= maxEst))
       {
         break;
       }
       else
       {
         if (numTries == 4)
         { 
           cout &lt;&lt; "ERROR: Exceeded max number of tries entering data" &lt;&lt; endl;
           return 0;
         }
         cout &lt;&lt; "" &lt;&lt; endl;
         cout &lt;&lt; "Value you entered was not in range\n";
         cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; minEst &lt;&lt; " &lt;= initial estimate &lt;= " &lt;&lt; maxEst &lt;&lt; endl;
       }
     }
     else
     {
  
     cout &lt;&lt; "The initial estimate was not a number\n";
     cin.clear();
  
     }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Result of this code: </p>
  
  <pre><code>Enter initial estimate of root : y
  The initial estimate was not a number
  Enter initial estimate of root : The initial estimate was not a number
  Enter initial estimate of root : The initial estimate was not a number
  Enter initial estimate of root : The initial estimate was not a number
  </code></pre>
  
  <p>I want: </p>
  
  <pre><code>Enter initial estimate of root : y
  The initial estimate was not a number
  Enter initial estimate of root : 
  </code></pre>
  
  <p>And have the user enter the next value!</p>