How to get random number generator to work properly : <p>My code deals with two dice (a 10 sided "fair" dice and a 20 sided "fair" dice) and using classes, arrays and a random number generator to generate random rolls of the two dice and their summation, but all my code spits out is "You rolled: 18". That is not very random. </p>

<pre><code>
#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;

using namespace std;

class Dice
{
  private:
  int rollDice[2] = {};

  public:
  void setval1(int x)
  {
    rollDice[0] = x;
  }

  void setval2(int y)
  {
    rollDice[1] = y;
  }

  double getVal1()
    {
      return rollDice[0];
    }

  double getVal2()
  {
    return rollDice[1];
  }
};

int main()
 {
  Dice a;
  a.setval1(rand()%9+1);
  a.setval2(rand()%19+1);
  cout &lt;&lt; "You rolled: " &lt;&lt; a.getVal1() + a.getVal2();
}

</code></pre>
