C++ cin positive integers only
<p>This is my first time on Stackoverflow.
I was making a program to find out MPG for a car. I was wondering how can I make the cin statement only accept positive integers only? and also, if you do enter a invalid input, can you reset it? I am not sure if that makes sense. I didn't have to do this for class. I was just curious on how to do it. Here is the code.</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main()
{
double tank, miles, mpg;

cout &lt;&lt; "Hello. This is a program that calculates the MPG ( Miles Per Gallon) for      your\n" ;
cout &lt;&lt; "vehicle\n" &lt;&lt; endl;
cout &lt;&lt; "Please enter how many gallons your vehicle can hold\n" &lt;&lt; endl;
cin &gt;&gt; tank;
cout &lt;&lt; endl;
cout &lt;&lt; "Please enter how many miles that have been driven on a full tank\n" &lt;&lt;endl;
cin &gt;&gt; miles;
cout &lt;&lt; endl;

mpg = (miles)/(tank);
cout &lt;&lt; "Your vehicle recieves " &lt;&lt; mpg &lt;&lt; " miles per gallon\n" &lt;&lt; endl;
system ("pause");
return 0;
}
</code></pre>
