title: terminate called after throwing an instance of 'std::out_of_range'
body: <p>I'm a absolute beginner for programming. I got this error while building up the following code.</p>
  
  <pre><code>error: terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 8) &gt;= this-&gt;size() (which is 8) Aborted (core dumped)
  </code></pre>
  
  <hr/>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;string&gt;
  #include&lt;iomanip&gt;
  using namespace std;
  int main()
  {
      cout&lt;&lt;"\n Welcome to space travel calculation program";
  
      string cPlanet, name;
      double weight, speed, tTime, nWeight;
      int num;
      vector&lt;string&gt; planet;
      vector&lt;int&gt; distance;
      vector&lt;double&gt; sGravity;
  
      planet.push_back("Mercury");
      distance.push_back(36);
      sGravity.push_back(0.27);
  
      planet.push_back("Venus");
      distance.push_back(67);
      sGravity.push_back(0.86);
  
      planet.push_back("Earth");
      distance.push_back(93);
      sGravity.push_back(1.00);
  
      planet.push_back("Mars");
      distance.push_back(141);
      sGravity.push_back(0.37);
  
      planet.push_back("Jupiter");
      distance.push_back(483);
      sGravity.push_back(2.64);
  
      planet.push_back("Saturn");
      distance.push_back(886);
      sGravity.push_back(1.17);
  
      planet.push_back("Uranus");
      distance.push_back(1782);
      sGravity.push_back(0.92);
  
      planet.push_back("Neptune");
      distance.push_back(2793);
      sGravity.push_back(1.44);
      num=planet.size();
  
      cout&lt;&lt;"\n Please tell me your name: ";
      getline(cin,name);
  
  
      cout&lt;&lt;"\n Please choose which planet you want to travel to from the following list:"
          &lt;&lt;"\n 1.Mercury"
          &lt;&lt;"\n 2.Venus"
          &lt;&lt;"\n 3.Earth"
          &lt;&lt;"\n 4.Mars"
          &lt;&lt;"\n 5.Jupiter"
          &lt;&lt;"\n 6.Saturn"
          &lt;&lt;"\n 7.Uranus"
          &lt;&lt;"\n 8.Neptune       :";
      getline(cin,cPlanet);
  
      cout&lt;&lt;"\n What is your weight on Earth?";
      cin&gt;&gt;weight;
  
      cout&lt;&lt;"\n At what speed do you wish to travel? :";
      cin&gt;&gt;speed;
  
      if(cPlanet==planet.at(num))
      {
          tTime=(distance.at(num))/speed;
          nWeight=weight*sGravity.at(num);
  
          cout&lt;&lt;"\n Your Name: "&lt;&lt;name
              &lt;&lt;"\n Weight On Earth: "&lt;&lt;weight
              &lt;&lt;"\n Planet you wish to visit: "&lt;&lt;cPlanet
              &lt;&lt;"\n The speed you will be travelling at: "&lt;&lt;speed
              &lt;&lt;"\n Total time it will take to reach "&lt;&lt;planet.at(num)&lt;&lt;": "&lt;&lt;tTime
              &lt;&lt;"\n Your weight on "&lt;&lt;planet.at(num)&lt;&lt;": "&lt;&lt;nWeight;
      }
  
      return 0;
  }
  </code></pre>