title: How do I check if input is an integer/string?
body: <p>My problem here is I don't know how to insert a rule wherein if a user inputted a number on the string, it will <code>cout</code> a warning saying it's not valid, same with if a user inputted a string/char on the grades. How? I've been trying it but the formula won't work. </p>
  
  <pre><code>int x, cstotal = 100, extotal = 150;
  
  double scorecs, exscore, labtotala, labtotalb, total;
  
  string mystr = "";
  
  cout &lt;&lt; "Compute for: " &lt;&lt; "\n" &lt;&lt; "1. Laboratory Grade " &lt;&lt; "\n" &lt;&lt; "2. Lecture Grade" &lt;&lt; "\n" &lt;&lt; "3. Exit" &lt;&lt; "\n";
  cout &lt;&lt; "Please enter a number: ";
  cin &gt;&gt; x;
  switch (x) {
  case 1:
  
      cout &lt;&lt; "Compute for laboratory grade." &lt;&lt; "\n";
      cout &lt;&lt; "Enter Student Name: ";
      cin &gt;&gt; mystr;
  
  
      cout &lt;&lt; "Good day, " &lt;&lt; mystr &lt;&lt; " . Please provide the following grades: " &lt;&lt; "\n";
      cout &lt;&lt; "CS Score: ";
      cin &gt;&gt; scorecs;
  
      cout &lt;&lt; "Exam Score: ";
      cin &gt;&gt; exscore;
  
  
      labtotala = scorecs / cstotal * 0.6;
      labtotalb = exscore / extotal * 0.4;
      total = labtotala + labtotalb;
      cout &lt;&lt; "Your Laboratory Grade is " &lt;&lt; total * 100 &lt;&lt; "\n";
      system("pause");
      break;
  case 2:
      cout &lt;&lt; "Compute for lecture grade." &lt;&lt; "\n";
      cout &lt;&lt; "Enter Student Name: ";
      cin &gt;&gt; mystr;
      cout &lt;&lt; "Good day, " &lt;&lt; mystr &lt;&lt; " . Please provide the following grades: " &lt;&lt; "\n";
      cout &lt;&lt; "CS Score: ";
      cin &gt;&gt; scorecs;
      cout &lt;&lt; "Exam Score: ";
  
      cin &gt;&gt; exscore;
      labtotala = scorecs / cstotal * 0.7;
      labtotalb = exscore / extotal * 0.3;
      total = labtotala + labtotalb;
      cout &lt;&lt; "Your Lecture Grade is " &lt;&lt; total * 100 &lt;&lt; "\n";
      system("pause");
      break;
  </code></pre>