I'm trying to write a blackjack game, but I ran into a problem with random integers. I'm to the point where the player has there original number, and they've chosen to hit. I need help figuring out how to make random_integer keep it's value, but then add another random integer to it. what I have now is just random_integer + random_integer, but that just doubles the original value of the original random_integer. So really what I'm asking is how to get two different random integers. I'll copy&paste what I have. Note that I'm jumping around a lot in this, so if you see errors elsewhere it's probably just because I haven't gotten to them yet lol.
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int number;
char ans;
char Ans;
int main(int argc, char *argv[])
{
do
{
cout << " Welcome to Blackjack\n";
cout <<"\n";
system("PAUSE");
cout << "\n";
#
srand((unsigned)time(0)); // generates random number.
int random_integer = rand();
int lowest=1, highest=12;
int range=(highest-lowest)+1;
for(int index=0; index<1; index++){
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
cout << "You've been dealt a(n) " << random_integer << endl;
cout << "\n";
}
if (random_integer==21) {
do
{
cout << "BACKJACK!!! \n";
cout << "\n";
cout << "Do you want to play agian? (y/n)\n";
cout <<"\n";
cin >> ans;
}
while((ans !='y')&&(ans !='n'));
if (ans=='y')
system("cls");
cout << "okay";
}
else if (ans=='n')
cout << "Goodbye!";
if (random_integer<21) {
cout << "to hit, press 1. to stay, press 2.\n";
cout << "\n";
cin >> Ans;
if(Ans=='1')
cout << "Now you're at " << random_integer + random_integer << ".";
<---------- this is what I'm talking about.