title: How to only accept numbers for multiple inputs
body: <p>I want the user to enter one value then another, for two variables. If their input is anything else than a number. They should get an error and the program loops back to the beginning. If there's a way so that the user enters both values. Then only after they've entered the two values for the two variables. The program checks if the value for both is a number and nothing else. Then it displays the stuff I want it to. But if they don't put in a number. An error pops up. I've seen some code on how to do this. But I couldn't figure out how to make it work for multiple inputs. Also the program still accepted non numbers. Like if you entered "50k". It will say you entered "50" and ignore that "k". I wish for it to not ignore that non number. Instead, make the user feel bad for doing so by displaying an error message. Here's my code.</p>
  
  <pre><code>//discordio
  // EXAM 01
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
      const int Load_cost = 50;
      const double Mile_cost = .50;
      int load = 0;
      double mile = 0;
      const double Mpg = 8;
      const double PerGal = 3;
      double total = 0;
      double fin1 = 0;
      double fin2 = 0;
      double fin3 = 0;
  
  
     cout &lt;&lt; "Welcome to discordio's Shipping! Please fill out the following." &lt;&lt; endl;
  
  cout &lt;&lt; "Number of loads: ";
  cin &gt;&gt; load;
  
  cout &lt;&lt; "Number of miles: ";
  cin &gt;&gt; mile;
  
  
  fin1 = load * Load_cost;
  fin2 = mile * Mile_cost;
  fin3 = mile / Mpg * PerGal;
  total = fin1 + fin2 + fin3;
  
  system("CLS");
  
  
  cout &lt;&lt; cout &lt;&lt; "\nWelcome to discordio's Shipping!  We welcome the opportunity to provide you with a quote." &lt;&lt; endl &lt;&lt; endl;
  cout &lt;&lt; fixed &lt;&lt; setprecision(2);
  cout &lt;&lt; "Shipping fee" &lt;&lt; setw(3) &lt;&lt; ":" &lt;&lt; setw(3) &lt;&lt; "$ " &lt;&lt; load * Load_cost &lt;&lt; endl &lt;&lt; endl;
  cout &lt;&lt; "Mileage" &lt;&lt; setw(8) &lt;&lt; ":" &lt;&lt; setw(3) &lt;&lt; "$ " &lt;&lt; mile * Mile_cost &lt;&lt; endl &lt;&lt; endl;
  cout &lt;&lt; "Fuel Surcharge:" &lt;&lt; setw(3) &lt;&lt; "$ " &lt;&lt; mile / Mpg * PerGal &lt;&lt; endl &lt;&lt; endl;
  cout &lt;&lt; "Total" &lt;&lt; setw(10) &lt;&lt; ":" &lt;&lt; setw(3) &lt;&lt; "$ " &lt;&lt; total &lt;&lt; endl;
  }
  </code></pre>
  
  <p>This is what I got for the basics of my homework (Sorry if this doesn't meet the criteria of most). I just need help adding errors for when both inputs are not numbers. If your code requires me to use an extra header file, please tell me. I'm still pretty new to this so I won't know what to add. Hope I covered enough in my question. Also please add code in your answer. If you could, make your code work if I paste into the IDE. I learn from manipulating things to find different results. So show don't tell.</p>